﻿using System;
using System.Collections.Generic;
using ESRI.ArcGIS;
using System.IO;
using System.Drawing;
using System.Drawing.Imaging;
using System.Data.OleDb;
using ESRI.ArcGIS.Display;
using ESRI.ArcGIS.Geometry;
using System.Runtime.InteropServices;
using System.Text;
using System.Diagnostics;
using System.Data;
using ExportArcSymbolToPng;
using SuperMap.Data;
using SuperMap.Mapping;
using ESRI.ArcGIS.Carto;
using ESRI.ArcGIS.esriSystem;
using ESRI.ArcGIS.Geodatabase;
using ESRI.ArcGIS.DataSourcesGDB;
using ESRI.ArcGIS.Geoprocessing;
using SuperMap.Data.Conversion;
using ESRI.ArcGIS.DataSourcesRaster;

namespace ArcStyleReader
{
    static class Program
    {
        private const string GDB_TABLE_MARKER = "MARKER SYMBOLS";
        private const string GDB_TABLE_LINE = "LINE SYMBOLS";
        private const string GDB_TABLE_AREA = "FILL SYMBOLS";
        private const string JET_SCHEMA_TABLE = "TABLE_NAME";
        private const string JET_SCHEMA_COLUMN = "COLUMN_NAME";
        private const string FIELD_ID = "ID";
        private const string FIELD_CATEGORY = "CATEGORY";
        private const string FIELD_NAME = "NAME";
        private static Color BACKCOLOR = Color.FromArgb(254, 253, 252);
        private static StreamWriter m_StreamWriter = null;
        private static bool m_IsConvertData = false;
        private static ISpatialReference pReference;
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(String[] args)
        {
            Console.Title = "地图文档转换";
            // 在10.3.1中该语句会抛异常，去掉之
            //ESRI.ArcGIS.RuntimeManager.BindLicense(ESRI.ArcGIS.ProductCode.Desktop);
            if (!RuntimeManager.Bind(ProductCode.Engine))
            {
                if (!RuntimeManager.Bind(ProductCode.Desktop))
                {
                    Console.WriteLine("Unable to bind to ArcGIS runtime. Application will be shut down.");
                    return;
                }
            }


            IAoInitialize m_AoInitialize = new AoInitializeClass();
            esriLicenseStatus licenseStatus = esriLicenseStatus.esriLicenseUnavailable;
            licenseStatus = m_AoInitialize.Initialize(esriLicenseProductCode.esriLicenseProductCodeEngine);

//             LicenseInitializer m_AOLicenseInitializer = new ddchGIPlatform.LicenseInitializer();
//             m_AOLicenseInitializer.InitializeApplication(new esriLicenseProductCode[] { esriLicenseProductCode.esriLicenseProductCodeEngineGeoDB },
//                         new esriLicenseExtensionCode[] { esriLicenseExtensionCode.esriLicenseExtensionCodeNetwork, esriLicenseExtensionCode.esriLicenseExtensionCodeSpatialAnalyst, esriLicenseExtensionCode.esriLicenseExtensionCodeSchematics, esriLicenseExtensionCode.esriLicenseExtensionCodeDataInteroperability });
//             Application.EnableVisualStyles();



            //开始写日志。
            string logPath = System.IO.Path.Combine("./log");
            if (!Directory.Exists(logPath))
                Directory.CreateDirectory(logPath);//不存在则创建log文件夹  
            string logFileName = logPath + "/" + System.DateTime.Now.ToString("yyyy-MM-dd-HH-mm-ss-ffff") + ".log";//生成日志文件 

            m_StreamWriter = File.CreateText(logFileName);

            int count = args.GetLength(0);
    
            if (count == 0)
            {
                Console.WriteLine("请输入转换参数");
                Console.WriteLine("******.style文件,用于符号库 ");
                Console.WriteLine("******.MXD文件,用于转换工作空间 ");

                Console.WriteLine("继续输入.....");
                string path = Console.ReadLine();
                if (File.Exists(path) == false)
                {
                    Console.WriteLine(path + "不存在");
                    Console.ReadLine();
                    return;
                }

                string extention = System.IO.Path.GetExtension(path);
                if (extention == ".mxd" || extention == ".MXD")
                {
                    Console.WriteLine("是否转换对应数据(Y/N)");
                    String flag = Console.ReadLine();

                    if (flag.Trim().ToUpper() == "Y")
                    {
                        m_IsConvertData = true;
                    }
                    else if (flag.Trim().ToUpper() == "N")
                    {
                        m_IsConvertData = false;
                    }
                    MXDToSMWU(@path);
                }
                else if (extention == ".style" || extention == ".STYLE")
                {
                    Output(@path);
                }
                else
                {
                    Console.WriteLine("输入依然错误！！");
                }
                return;
            }

            for (int i = 0; i < count; i++)
            {
                string path = args[i];
                string extention = System.IO.Path.GetExtension(path);
                if (extention == ".mxd" || extention == ".MXD")
                {
                    try
                    {
                        Console.WriteLine("是否转换对应数据(Y/N)");
                        String flag = Console.ReadLine();

                        if (flag == "Y")
                        {
                            m_IsConvertData = true;
                        }
                        else if (flag == "N")
                        {
                            m_IsConvertData = false;
                        }

                        MXDToSMWU(@path);
                    }
                    catch(Exception ex)
                    {
                        Console.WriteLine(ex.Message);
                        Log(ex.Message);
                    }
                }
                else if (extention == ".style" || extention == ".STYLE")
                {
                    Output(@path);
                }
                else
                {
                    Console.WriteLine("文件错误！");
                }
            }
            Log(String.Format("Info:工作空间输出路径为：{0}\r\n", System.IO.Directory.GetCurrentDirectory()));
            Log("Attention !!: 转换结束，打开supermap工作空间时请手动指定地图投影方式!!\r\n");
            
            Console.WriteLine("工作空间输出路径为：{0}", System.IO.Directory.GetCurrentDirectory());
            Console.WriteLine("...............................结束...............................");
            Console.ReadKey();
        }

        public static void ConvertArcgisFeatureClassData(String filePath, String layerName, String workspaceName, Datasources datasources)
        {
            if (!m_IsConvertData)
            {
                return;
            }
            Boolean isExsite = Directory.Exists(filePath);
            String extension = System.IO.Path.GetExtension(filePath);
            IFeatureWorkspace pFeatrueWorkspace = null;
            if (isExsite)
            {
                if (extension.ToUpper() == ".GDB")
                {
                    //这是用的最多的一种方式,如果是FileGeodatabasse,则将

                    FileGDBWorkspaceFactory GDBWSF = new FileGDBWorkspaceFactory();

                    pFeatrueWorkspace = GDBWSF.OpenFromFile(filePath, 0) as IFeatureWorkspace;
                }
                else if (extension.ToUpper() == ".MDB")
                {
                    //ArcEngine中个人数据库为Access。
                    AccessWorkspaceFactory AWSF = new AccessWorkspaceFactoryClass();

                    pFeatrueWorkspace = AWSF.OpenFromFile(filePath, 0) as IFeatureWorkspace;
                }
                else if (extension.ToUpper() == "" && workspaceName == "Shapefile Data")
                {
                    Console.WriteLine("{0}:该类型直接导入udb", workspaceName);
                }
                else
                {
                    Console.WriteLine("{0}:暂时不支持的数据库类型", extension.ToUpper());
                }
            }
            else
            {
                Log(String.Format("error:<{0}>此路径下没有数据，请检查", filePath));
                Console.WriteLine("{0}:数据库不存在，请检查", filePath);
            }

            if (pFeatrueWorkspace != null)
            {
                IWorkspace pWorkSpace = pFeatrueWorkspace as IWorkspace;
                IEnumDataset ienum = pWorkSpace.get_Datasets(esriDatasetType.esriDTAny);
                IDataset iDataset = ienum.Next();
               
                //设置参数  

                IGeoProcessor2 gp2 = new GeoProcessorClass(); 
                gp2.OverwriteOutput = true;
                
                ESRI.ArcGIS.ConversionTools.FeatureClassToShapefile intersect = new ESRI.ArcGIS.ConversionTools.FeatureClassToShapefile();
                IFeatureClass featrueClass = pFeatrueWorkspace.OpenFeatureClass(layerName);
                String InPath = "";
                IFeatureDataset pfeatureDataset = featrueClass.FeatureDataset;
                if (pfeatureDataset != null)
                {
                   if (pfeatureDataset.BrowseName == "")
                   {
                       InPath = filePath + "\\" + layerName;
                   }
                   else
                   {
                       InPath = filePath + "\\" + pfeatureDataset.BrowseName + "\\" + layerName;
                   }
                }
                else
                {
                    InPath = filePath + "\\" + layerName;
                }
                     
                String outputDir = Directory.GetParent(filePath).FullName + "\\Temp\\";
                if (!Directory.Exists(outputDir))
                {
                    Directory.CreateDirectory(outputDir);
                }
                //构造Geoprocessor  
                GeoProcessor gp = new GeoProcessor();
                IVariantArray parameters = new VarArrayClass();
                parameters.Add(InPath);
                parameters.Add(outputDir);
                gp.Execute("FeatureClassToShapefile_conversion", parameters, null);
                                
                Datasets tempDatasets = null;
                DatasourceConnectionInfo coninfo = new DatasourceConnectionInfo();
                coninfo.Alias = workspaceName;
                coninfo.Server = Directory.GetCurrentDirectory() + "\\" + workspaceName + ".udb";
                coninfo.EngineType = EngineType.UDB;
                Datasource datasource = null;
                if (!File.Exists("./" + workspaceName + ".udb"))
                {
                    datasource = datasources.Create(coninfo);
                    tempDatasets = datasource.Datasets;

                }
                else
                {
                    if (datasources.Contains(workspaceName))
                    {
                        datasource = datasources[workspaceName];
                    }
                }
                DataImport dataImport = new DataImport();
                ImportSettingSHP importsetting = new ImportSettingSHP();
                importsetting.SourceFilePath = outputDir + layerName + ".shp";
                importsetting.TargetDatasource = datasource;
                importsetting.TargetDatasetName = layerName;
                importsetting.ImportMode = ImportMode.Overwrite;
                dataImport.ImportSettings.Add(importsetting);

                ImportResult result = dataImport.Run();

                if (result.SucceedSettings.GetLength(0) >= 1)
                {
                    Console.WriteLine("<{0}> 被成功导入到<{1}>", layerName, workspaceName);
                }
                else
                {
                    Console.WriteLine("该图层<{0}>对应数据为空", layerName);
                }
            }
            else if (extension.ToUpper() == "" && workspaceName == "Shapefile Data")
            {
                String outputDir = filePath;
                Datasets tempDatasets = null;
                DatasourceConnectionInfo coninfo = new DatasourceConnectionInfo();
                coninfo.Alias = workspaceName;
                coninfo.Server = Directory.GetCurrentDirectory() + "\\" + workspaceName + ".udb";
                coninfo.EngineType = EngineType.UDB;
                Datasource datasource = null;
                if (!File.Exists("./" + workspaceName + ".udb"))
                {
                    datasource = datasources.Create(coninfo);
                    tempDatasets = datasource.Datasets;

                }
                else
                {
                    if (datasources.Contains(workspaceName))
                    {
                        datasource = datasources[workspaceName];
                    }
                }
                DataImport dataImport = new DataImport();
                ImportSettingSHP importsetting = new ImportSettingSHP();
                importsetting.SourceFilePath = outputDir + "\\" +layerName + ".shp";
                importsetting.TargetDatasource = datasource;
                importsetting.TargetDatasetName = layerName;
                importsetting.ImportMode = ImportMode.Overwrite;
                dataImport.ImportSettings.Add(importsetting);

                ImportResult result = dataImport.Run();

                if (result.SucceedSettings.GetLength(0) >= 1)
                {
                    Console.WriteLine("<{0}> 被成功导入到<{1}>", layerName, workspaceName);
                }
                else
                {
                    Console.WriteLine("该图层<{0}>对应数据为空", layerName);
                }
            }
            else
            {
                Console.WriteLine("创建featureWorkspace失败");
            }
        }

        public static void ConvertArcgisRasterData(String filePath, String layerName, String workspaceName, Datasources datasources)
        {
            if (!m_IsConvertData)
            {
                return;
            }
            Boolean isExsite = Directory.Exists(filePath);
            String extension = System.IO.Path.GetExtension(filePath);
            IRasterWorkspaceEx pRasterWorkspaceEX = null;
            if (isExsite)
            {
                if (extension.ToUpper() == ".GDB")
                {
                    //这是用的最多的一种方式,如果是FileGeodatabasse,则将

                    FileGDBWorkspaceFactory GDBWSF = new FileGDBWorkspaceFactory();
                    IWorkspace pp = GDBWSF.OpenFromFile(filePath, 0);
                    pRasterWorkspaceEX = GDBWSF.OpenFromFile(filePath, 0) as IRasterWorkspaceEx;
                }
                else if (extension.ToUpper() == ".MDB")
                {
                    //ArcEngine中个人数据库为Access。
                    AccessWorkspaceFactory AWSF = new AccessWorkspaceFactoryClass();

                    pRasterWorkspaceEX = AWSF.OpenFromFile(filePath, 0) as IRasterWorkspaceEx;
                }
                else
                {
                    Console.WriteLine("{0}:暂时不支持的数据库类型", extension.ToUpper());
                }
            }
            else
            {
                Console.WriteLine("{0}:数据库不存在，请检查", filePath);
            }

            if (pRasterWorkspaceEX != null)
            {
                //设置参数  
                ESRI.ArcGIS.ConversionTools.FeatureClassToShapefile intersect = new ESRI.ArcGIS.ConversionTools.FeatureClassToShapefile();
                IRasterCatalog rastercata = pRasterWorkspaceEX.OpenRasterCatalog(layerName);
                IRasterDataset rasterDataset = pRasterWorkspaceEX.OpenRasterDataset(layerName);
                String InPath = filePath + "\\" + layerName;
              
                String outputDir = Directory.GetParent(filePath).FullName + "\\Temp\\";
                if (!Directory.Exists(outputDir))
                {
                    Directory.CreateDirectory(outputDir);
                }
                //构造Geoprocessor  
                IGeoProcessor2 gp = new GeoProcessorClass();
                gp.OverwriteOutput = true;
                IVariantArray parameters = new VarArrayClass();
                parameters.Add(InPath);
                parameters.Add(outputDir);
                parameters.Add("TIFF");
                gp.Execute("RasterToOtherFormat_conversion", parameters, null);

                Datasets tempDatasets = null;
                DatasourceConnectionInfo coninfo = new DatasourceConnectionInfo();
                coninfo.Alias = workspaceName;
                coninfo.Server = Directory.GetCurrentDirectory() + "\\" + workspaceName + ".udb";
                coninfo.EngineType = EngineType.UDB;
                Datasource datasource = null;
                if (!File.Exists("./" + workspaceName + ".udb"))
                {
                    datasource = datasources.Create(coninfo);
                    tempDatasets = datasource.Datasets;

                }
                else
                {
                    if (datasources.Contains(workspaceName))
                    {
                        datasource = datasources[workspaceName];
                    }
                }
                DataImport dataImport = new DataImport();
                ImportSettingTIF importsetting = new ImportSettingTIF();
                importsetting.SourceFilePath = outputDir + layerName + ".tif";
                importsetting.TargetDatasource = datasource;
                importsetting.TargetDatasetName = layerName;
                importsetting.ImportMode = ImportMode.Overwrite;
                importsetting.ImportingAsGrid = true;
                dataImport.ImportSettings.Add(importsetting);

                ImportResult result = dataImport.Run();

                if (result.SucceedSettings.GetLength(0) >= 1)
                {
                    Console.WriteLine("<{0}> 被成功导入到<{1}>", layerName, workspaceName);
                }
                else
                {
                    Console.WriteLine("该图层<{0}>对应数据为空", layerName);
                }
            }
            else
            {
                Console.WriteLine("创建featureWorkspace失败");
            }
        }

        public static void MXDToSMWU(string mxdPath)
        {
            IMapDocument pMapDocument = new MapDocumentClass();

            string path = @mxdPath;

            string directoryname = System.IO.Path.GetDirectoryName(path);
            WorkspaceConnectionInfo conInfo = new WorkspaceConnectionInfo(directoryname + @"/" + System.IO.Path.GetFileNameWithoutExtension(path) + "_MXDtoSXWU.sxwu");
            SuperMap.Data.Workspace m_workspace = new SuperMap.Data.Workspace();
            m_workspace.Create(conInfo);
            m_workspace.Open(conInfo);
            Resources supermapResource = m_workspace.Resources;
            SymbolMarkerLibrary supermapMakerLibrary = supermapResource.MarkerLibrary;
            SymbolFillLibrary supermapfillLibrary = supermapResource.FillLibrary;
            SymbolLineLibrary supermapLineLibrary = supermapResource.LineLibrary;


            Datasources datasources = m_workspace.Datasources;
            SuperMap.Mapping.Map map = new SuperMap.Mapping.Map(m_workspace);
            Maps maps = m_workspace.Maps;

            if (pMapDocument.get_IsMapDocument(path))
            {
                pMapDocument.Open(path, null);
                
                IMap pMap;

                string Caption = pMapDocument.DocumentFilename;

                m_workspace.Caption = System.IO.Path.GetFileNameWithoutExtension(Caption);

                string Description = "this is a MXD  workspace";

                m_workspace.Description = Description;

                //对maps进行解析                             

                Console.WriteLine("开始解析MXD中地图图层信息");

                Console.WriteLine("共有 {0} 张地图", pMapDocument.MapCount);
                Log(String.Format("Info:共有 {0} 张地图", pMapDocument.MapCount));

                for (int i = 0; i <= pMapDocument.MapCount - 1; i++)
                {                   
                    pMap = pMapDocument.get_Map(i);
                    pReference = pMap.SpatialReference;
                    map.Name = pMap.Name;
                    map.Scale = pMap.MapScale;
                    esriUnits unit = pMap.MapUnits;

                    Log(String.Format("Info:地图：{0} 共有 {1} 个图层", map.Name,pMap.LayerCount.ToString()));
                    switch (unit)
                    {
                        case esriUnits.esriKilometers:
                            map.DistanceUnit = Unit.Kilometer;
                            break;
                        case esriUnits.esriDecimeters:
                            map.DistanceUnit = Unit.Decimeter;
                            break;
                        case esriUnits.esriCentimeters:
                            map.DistanceUnit = Unit.Centimeter;
                            break;
                        case esriUnits.esriMeters:
                            map.DistanceUnit = Unit.Meter;
                            break;
                        case esriUnits.esriYards:
                            map.DistanceUnit = Unit.Yard;
                            break;
                        case esriUnits.esriMiles:
                            map.DistanceUnit = Unit.Mile;
                            break;
                        case esriUnits.esriFeet:
                            map.DistanceUnit = Unit.Foot;
                            break;
                        case esriUnits.esriInches:
                            map.DistanceUnit = Unit.Inch;
                            break;
                        case esriUnits.esriDecimalDegrees:
                            map.DistanceUnit = Unit.Degree;
                            break;
                        default:
                            map.DistanceUnit = Unit.Kilometer;
                            break;
                    }
                    map.Description = pMap.Description;

                    IEnumLayer pEnumLayer = pMap.get_Layers();
                    pEnumLayer.Reset();
                    ILayer pLayer = pEnumLayer.Next();

                    Console.WriteLine("开始解析地图{0}", pMap.Name);
                    Log(String.Format("Info：开始解析地图{0}\n", pMap.Name));

                    List<Layer> layerList = new List<Layer>();
                    List<Theme> themeList = new List<Theme>();
                    Datasets datasets = null;
                    while (pLayer != null)
                    {
                        Console.WriteLine("开始解析图层{0}", pLayer.Name);
                        Log(String.Format("Info:开始解析图层{0}\r\n", pLayer.Name));
                        if (pLayer is GroupLayer)
                        {
                            Console.WriteLine("该图层 {0}为 GroupLayer 对应supermap 分组图层",pLayer.Name);
                            Log(String.Format("Info:该图层 {0} 为 GroupLayer 对应supermap 分组图层\r\n", pLayer.Name));
                            IGroupLayer pGrouplayer = (IGroupLayer)pLayer;
                            ICompositeLayer pCompositeLayer = pGrouplayer as ICompositeLayer;
                            int layerCount = pCompositeLayer.Count;
                            LayerGroup layerGroup = new LayerGroup(pGrouplayer.Name);
                            layerGroup.MinVisibleScale = pGrouplayer.MinimumScale;
                            if (pGrouplayer.MinimumScale != 0)
                            {
                                layerGroup.MinVisibleScale = 1.0 / pGrouplayer.MinimumScale;
                            }

                            layerGroup.MaxVisibleScale = pGrouplayer.MaximumScale;
                            if (pGrouplayer.MaximumScale != 0)
                            {
                                layerGroup.MaxVisibleScale = 1.0 / pGrouplayer.MaximumScale;
                            }

                            layerGroup.IsVisible = pGrouplayer.Visible;

                            map.Layers.Add(layerGroup);
                            convertToGroupLayer(pGrouplayer, layerGroup, datasets, datasources, pEnumLayer,
                                supermapResource, layerList, themeList);

                            Console.WriteLine("成功将GroupLayer: <{0}> 存入supermap分组图层",pLayer.Name);
                            Log(String.Format("Info :成功将GroupLayer :< {0} >存入supermap分组图层",pLayer.Name));
                        }
                        else if (pLayer is FeatureLayer)
                        {
                            DatasetVector datasetVector = null;
                            Console.WriteLine("该图层为 FeatureLayer 对应supermap 矢量图层 和 专题图层");
                            Log("Info :该图层为 FeatureLayer 对应supermap 矢量图层 和 专题图层");
                            //通过featurelayer获得geofeaturelayer
                            IFeatureLayer2 pFeatureLayer = pLayer as IFeatureLayer2;
                            IGeoFeatureLayer geolayer = pFeatureLayer as IGeoFeatureLayer;
                            if (geolayer == null)
                            {
                                continue;
                            }

                            IFeatureRenderer featureRenderer = geolayer.Renderer;

                            //获取
                            IDataLayer2 dataLater = pFeatureLayer as IDataLayer2;
                            IDatasetName pDN = dataLater.DataSourceName as IDatasetName;

                            //根据arcgis类型创建supermaplayer
                            esriGeometryType type = pFeatureLayer.ShapeType;
                            DatasetVectorInfo vectorInfo = null;

                            //避免名字转换冲突，事先判断

                            string workspaceName = pDN.WorkspaceName.BrowseName;
                            string workspacepath = pDN.WorkspaceName.PathName;

                            if (workspaceName == "Shapefile Data")
                            {
                                Console.WriteLine("使用的数据为shape file文件，请将文件导出到udb中使用，命名为 Shapefile Data ");
                            }

                            Datasets tempDatasets = null;
                            DatasourceConnectionInfo coninfo = new DatasourceConnectionInfo();
                            coninfo.Alias = workspaceName;
                            coninfo.Server = "./" + workspaceName + ".udb";
                            coninfo.EngineType = EngineType.UDB;
                            if (File.Exists("./" + workspaceName + ".udb"))
                            {

                                if (datasources.Contains(workspaceName))
                                {
                                    Datasource datasource = datasources[workspaceName];
                                    tempDatasets = datasource.Datasets;
                                }
                                else
                                {
                                    Datasource datasource = datasources.Open(coninfo);
                                    tempDatasets = datasource.Datasets;
                                }

                            }
                            else
                            {
                                Datasource datasource = datasources.Create(coninfo);
                                tempDatasets = datasource.Datasets;
                            }

                            string datasetNameSrc = pDN.Name;
                            ConvertArcgisFeatureClassData(workspacepath, datasetNameSrc, workspaceName, datasources);        
                            if (datasetNameSrc.Length >= 30)
                            {
                                datasetNameSrc = datasetNameSrc.Substring(0, 27);
                            }

                            string datasetNameDes = datasetNameSrc;

                            try
                            {
                                datasetNameDes = datasetNameDes.Replace("-", "");
                                Convert.ToInt32(datasetNameDes.Substring(0, 1));
                                datasetNameDes = "T" + datasetNameDes;
                            }
                            catch (Exception )
                            {

                            }

                            if (type == esriGeometryType.esriGeometryPoint)
                            {
                                vectorInfo = new DatasetVectorInfo(datasetNameDes, DatasetType.Point);
                            }
                            else if (type == esriGeometryType.esriGeometryLine || type == esriGeometryType.esriGeometryPolyline)
                            {
                                vectorInfo = new DatasetVectorInfo(datasetNameDes, DatasetType.Line);
                            }
                            else if (type == esriGeometryType.esriGeometryPolygon)
                            {
                                vectorInfo = new DatasetVectorInfo(datasetNameDes, DatasetType.Region);
                            }
                            else
                            {
                                vectorInfo = new DatasetVectorInfo(datasetNameDes, DatasetType.Point);
                            }

                            if (tempDatasets.Contains(datasetNameDes))
                            {
                                datasetVector = tempDatasets[datasetNameDes] as DatasetVector;
                            }
                            else
                            {

                                //创建图层，解析图层基本信息
                                datasetVector = tempDatasets.Create(vectorInfo);
                            }


                            IAnnotateLayerPropertiesCollection annotateLayerPropertiesCollection = geolayer.AnnotationProperties;
                            //解析mxd图层中的标签
                            Console.WriteLine("解析mxd图层中的标签，MXD的一个图层中可以由一个或多个字段生成多个子层，类似于superma的多个标签专题图");
                            Log("Info :解析mxd图层中的标签，MXD的一个图层中可以由一个或多个字段生成多个子层，类似于superma的多个标签专题图");

                            esriGeometryType type1 = pFeatureLayer.ShapeType;
                            for (int k = 0; k < annotateLayerPropertiesCollection.Count; k++)
                            {
                                IAnnotateLayerProperties Item;
                                IElementCollection placedElements;
                                IElementCollection unplacedElements;
                                annotateLayerPropertiesCollection.QueryItem(k, out Item, out placedElements, out unplacedElements);

                                LabelEngineLayerProperties labelproperty = Item as LabelEngineLayerProperties;
                                ILabelEngineLayerProperties2 ilabelproperty = labelproperty as ILabelEngineLayerProperties2;
                                IOverposterLayerProperties iOverposterLayerProperties = ilabelproperty.OverposterLayerProperties;
                                //                         //IBasicOverposterLayerProperties iBasicOverposterLayerProperties = ilabelproperty.BasicOverposterLayerProperties;
                                MaplexLabelEngineLayerProperties maplexLabelEngine = ilabelproperty as MaplexLabelEngineLayerProperties;

                                string labelpression = ilabelproperty.Expression;
                                bool flag = ilabelproperty.IsExpressionSimple;
                                ITextSymbol iTextSymbol = ilabelproperty.Symbol;

                                ThemeLabel supermapThemelabel = new ThemeLabel();

                                labelpression = labelpression.Substring(1, labelpression.Length - 2);

                                if (ilabelproperty.IsExpressionSimple == false)
                                {
                                    Console.WriteLine("图层  {0}  中，存在supermap无法识别的标签专题图字段 {1},该字段为复杂字段，supermap中不支持", pLayer.Name, ilabelproperty.Expression);
                                    Log(String.Format("Error :图层  {0}  中，存在supermap无法识别的标签专题图字段 {1},该字段为复杂字段，supermap中不支持", pLayer.Name, ilabelproperty.Expression));
                                    labelpression = null;
                                }
                                else if (labelpression.Contains("[") || labelpression.Contains("]"))
                                {
                                    Console.WriteLine("图层  {0}  中，存在supermap无法识别的标签专题图字段 {1}", pLayer.Name, ilabelproperty.Expression);
                                    Log(String.Format("Error :图层  {0}  中，存在supermap无法识别的标签专题图字段 {1}", pLayer.Name, ilabelproperty.Expression));
                                    labelpression = null;
                                }

                                supermapThemelabel.LabelExpression = labelpression;
                                TextStyle supermaptextStyle = new TextStyle();

                                //文字风格 
                                IFormattedTextSymbol formattedsymbol = iTextSymbol as IFormattedTextSymbol;
                                stdole.IFontDisp fontDisp = iTextSymbol.Font;

                                TextSymbol textSymbol = iTextSymbol as TextSymbol;
                                IMask mask = textSymbol as IMask;
                                IFillSymbol maskFillSymbol = mask.MaskSymbol;

                                supermaptextStyle.Bold = fontDisp.Bold;
                                supermaptextStyle.FontName = fontDisp.Name;
                                supermaptextStyle.Italic = fontDisp.Italic;
                                supermaptextStyle.Underline = fontDisp.Underline;
                                supermaptextStyle.Strikeout = fontDisp.Strikethrough;

                                if (formattedsymbol.ShadowXOffset != 0 || formattedsymbol.ShadowYOffset != 0)
                                {
                                    Log(String.Format("Warning:图层  {0}  中存在文字阴影，supermap对文字阴影的支持比较简洁,不够完善", pLayer.Name));
                                    supermaptextStyle.Shadow = true;
                                }

                                if (type == esriGeometryType.esriGeometryPoint)
                                {
                                    //访问maplex标注引擎
                                    IMaplexOverposterLayerProperties pMaplexPro = iOverposterLayerProperties as IMaplexOverposterLayerProperties;

                                    esriMaplexPointPlacementMethod method = esriMaplexPointPlacementMethod.esriMaplexSoutheastOfPoint;
                                    //仅针对点图层设置对其方式
                                    if (pMaplexPro != null)
                                    {
                                        method = pMaplexPro.PointPlacementMethod;
                                    }

                                    //该值为标注的优先级设定
                                    //IPointPlacementPriorities properties = pMaplexPro.PointPlacementPriorities;
                                    if (method == esriMaplexPointPlacementMethod.esriMaplexSoutheastOfPoint)
                                    {
                                        supermaptextStyle.Alignment = TextAlignment.TopLeft;
                                    }
                                    else if (method == esriMaplexPointPlacementMethod.esriMaplexSouthOfPoint)
                                    {
                                        supermaptextStyle.Alignment = TextAlignment.TopCenter;
                                    }
                                    else if (method == esriMaplexPointPlacementMethod.esriMaplexSouthwestOfPoint)
                                    {
                                        supermaptextStyle.Alignment = TextAlignment.TopRight;
                                    }
                                    else if (method == esriMaplexPointPlacementMethod.esriMaplexNortheastOfPoint)
                                    {
                                        supermaptextStyle.Alignment = TextAlignment.BottomLeft;
                                    }
                                    else if (method == esriMaplexPointPlacementMethod.esriMaplexNorthOfPoint)
                                    {
                                        supermaptextStyle.Alignment = TextAlignment.BottomCenter;
                                    }
                                    else if (method == esriMaplexPointPlacementMethod.esriMaplexNorthwestOfPoint)
                                    {
                                        supermaptextStyle.Alignment = TextAlignment.BottomRight;
                                    }
                                    else if (method == esriMaplexPointPlacementMethod.esriMaplexCenteredOnPoint)
                                    {
                                        supermaptextStyle.Alignment = TextAlignment.MiddleCenter;
                                    }
                                    else if (method == esriMaplexPointPlacementMethod.esriMaplexWestOfPoint)
                                    {
                                        supermaptextStyle.Alignment = TextAlignment.MiddleRight;
                                    }
                                    else if (method == esriMaplexPointPlacementMethod.esriMaplexEastOfPoint)
                                    {
                                        supermaptextStyle.Alignment = TextAlignment.MiddleLeft;
                                    }
                                    else
                                    {
                                        supermaptextStyle.Alignment = TextAlignment.TopLeft;
                                    }
                                }

                                decimal deci = fontDisp.Size;
                                //arcmap中单位好像和supermap对不上
                                supermaptextStyle.FontHeight = (iTextSymbol.Size + 3) * 25.4 / 72; //Convert.ToInt16(deci);
                                supermaptextStyle.Weight = fontDisp.Weight;
                                IColor iColor = iTextSymbol.Color;

                                supermaptextStyle.Outline = (int)(mask.MaskSize * 25.4 / 72) == 0.0 ? false : true;
                                if (iTextSymbol.Size > 10)
                                {
                                    supermaptextStyle.OutlineWidth = (int)mask.MaskSize;
                                }
                                if (mask.MaskSymbol != null)
                                {
                                    supermaptextStyle.BackColor = ConvertToSystemColor(mask.MaskSymbol.Color);
                                }
                                else
                                {
                                    supermaptextStyle.BackColor = Color.FromArgb(255, 255, 255, 255);
                                }


                                supermaptextStyle.ForeColor = ConvertToSystemColor(iColor);
                                supermapThemelabel.UniformStyle = supermaptextStyle;

                                map.Layers.Insert(0, datasetVector, supermapThemelabel);
                                Layer layer = map.Layers[0];
                                themeList.Add(supermapThemelabel);
                                if (Item.Class == "Default" && annotateLayerPropertiesCollection.Count == 1)
                                {
                                    layer.Caption = pLayer.Name;
                                }
                                else
                                {
                                    layer.Caption = Item.Class;
                                }
                                layer.IsVisible = geolayer.DisplayAnnotation;
                                layer.MaxVisibleScale = Item.AnnotationMaximumScale;
                                layer.MinVisibleScale = Item.AnnotationMinimumScale;
                                QueryParameter param = new QueryParameter();

                                param.AttributeFilter = Item.WhereClause;
                                layer.DisplayFilter = param;

                                
                                layerList.Add(layer);
                            }


                            //单值渲染器
                            if (featureRenderer is UniqueValueRenderer)
                            {
                                //该图层为单值渲染图层 
                                ThemeUnique supermapThemeuniqu = new ThemeUnique();


                                IUniqueValueRenderer uniqueRender = featureRenderer as IUniqueValueRenderer;
                                int fieldCount = uniqueRender.FieldCount;
                                int valueCount = uniqueRender.ValueCount;


                                string fieldString = "";
                                if (fieldCount > 1)
                                {
                                    //如果多个字段为数值，会导致数值相加
                                    Console.WriteLine("mxd中采用的多字段控制单值，supermap对此支持不完全");
                                    Log(String.Format("Warning :采用的多字段控制单值，supermap对此支持不完全,图层：{0}", pLayer.Name));
                                }
                                for (int k = 0; k < fieldCount; k++)
                                {
                                    fieldString += uniqueRender.Field[0];
                                }

                                supermapThemeuniqu.UniqueExpression = uniqueRender.Field[0];

                                Log("Warning :mxd中采用多个单值指定为一个单值项，supermap中只能采用将某些单值项指定为相同的符号来实现");
                                Console.WriteLine("mxd中采用多个单值指定为一个单值项，supermap中只能采用将某些单值项指定为相同的符号来实现");
                                GeoStyle supermapGeoStyle = new GeoStyle();
                                for (int m = 0; m < valueCount; m++)
                                {
                                    ThemeUniqueItem supermapThemeitem = new ThemeUniqueItem();

                                    string uniqueVal = uniqueRender.get_Value(m);
                                    ISymbol pSymbol = uniqueRender.get_Symbol(uniqueVal);

                                    supermapThemeitem.Caption = uniqueRender.get_Label(uniqueVal);
                                    supermapThemeitem.IsVisible = true;//esri中没有根据每个段的可见性设置
                                    supermapThemeitem.Unique = uniqueVal;
                                    if (pSymbol == null)
                                    {
                                        supermapThemeitem.Style = supermapGeoStyle;
                                        supermapThemeuniqu.Add(supermapThemeitem);
                                        continue;
                                    }

                                    SymbolizeToSuperMapSymbolLib(supermapGeoStyle, supermapResource, pSymbol, supermapThemeitem.Caption);
                                    supermapThemeitem.Style = supermapGeoStyle;
                                    supermapThemeuniqu.Add(supermapThemeitem);
                                }

                                ISymbol defaultSymbol = uniqueRender.DefaultSymbol;
                                Boolean isDisplayDefault = uniqueRender.UseDefaultSymbol;
                                GeoStyle geoStyle = new GeoStyle();
                                SymbolizeToSuperMapSymbolLib(geoStyle, supermapResource, defaultSymbol, "other Values");
                                supermapThemeuniqu.DefaultStyle = geoStyle;
                                supermapThemeuniqu.IsDefaultStyleVisible = isDisplayDefault;

                                map.Layers.Add(datasetVector, supermapThemeuniqu,false);
                                Layer uniqueRendererlayer = map.Layers[map.Layers.Count - 1];

                                uniqueRendererlayer.MinVisibleScale = pLayer.MinimumScale;
                                uniqueRendererlayer.MaxVisibleScale = pLayer.MaximumScale;
                                uniqueRendererlayer.Caption = pLayer.Name;
                                themeList.Add(supermapThemeuniqu);

                                IFeatureLayerDefinition2 featureLayerDefine = pFeatureLayer as IFeatureLayerDefinition2;
                                QueryParameter param = new QueryParameter();
                                param.AttributeFilter = featureLayerDefine.DefinitionExpression;
                                uniqueRendererlayer.DisplayFilter = param;
                               
                                layerList.Add(uniqueRendererlayer);
                            }
                            //A renderer that can be used to draw graduated color (choropleth) and graduated symbol maps.
                            else if (featureRenderer is ClassBreaksRenderer)
                            {
                                IClassBreaksRenderer classBrakRender = featureRenderer as ClassBreaksRenderer;
                                string displayField = classBrakRender.Field;
                                string normalizeField = classBrakRender.NormField;
                                int breakcount = classBrakRender.BreakCount;
                                SuperMap.Mapping.ThemeRange supermapThemeRange = new SuperMap.Mapping.ThemeRange();
                                //supermapThemeRange.RangeMode = RangeMode.CustomInterval;
                                supermapThemeRange.RangeExpression = displayField;
                                supermapThemeRange.Precision = 0.0000001;

                                themeList.Add(supermapThemeRange);
                                Double minValue = Double.MinValue;

                                for (int k = 0; k < breakcount; k++)
                                {
                                    SuperMap.Mapping.ThemeRangeItem supermapThemeitem = new SuperMap.Mapping.ThemeRangeItem();
                                    supermapThemeitem.Caption = classBrakRender.Label[k];
                                    supermapThemeitem.Start = minValue;
                                    supermapThemeitem.End = classBrakRender.get_Break(k) + 0.0000001;
                                    minValue = supermapThemeitem.End;

                                    ISymbol pSymbol = classBrakRender.Symbol[k];

                                    if (pSymbol is IFillSymbol)
                                    {
                                        GeoStyle supermapGeoStyle = new GeoStyle();
                                        SymbolizeToSuperMapSymbolLib(supermapGeoStyle, supermapResource, pSymbol, supermapThemeitem.Caption);
                                        supermapThemeitem.Style = supermapGeoStyle;
                                        supermapThemeRange.AddToTail(supermapThemeitem);
                                    }
                                    else
                                    {
                                        Console.WriteLine("改分段专题图为点符号分段，supermap中不支持改分段专题图");
                                        Log("Error:改分段专题图为点符号分段，supermap中不支持改分段专题图");
                                        continue;
                                    }
                                }

                                map.Layers.Add(datasetVector, supermapThemeRange,false);
                                Layer rangeRendererlayer = map.Layers[map.Layers.Count - 1];
                                rangeRendererlayer.Caption = pLayer.Name;
                                IFeatureLayerDefinition2 featureLayerDefine = pFeatureLayer as IFeatureLayerDefinition2;
                                QueryParameter param = new QueryParameter();
                                param.AttributeFilter = featureLayerDefine.DefinitionExpression;
                                rangeRendererlayer.DisplayFilter = param;                                
                            }
                            //简单渲染器，统一风格
                            //简单专题图就是supermap的普通图层
                            else if (featureRenderer is SimpleRenderer)
                            {
                                SimpleRenderer simpleRender = featureRenderer as SimpleRenderer;
                                ISymbol pSymbol = simpleRender.Symbol;

                                LayerSettingVector supermapLayersettingVector = new LayerSettingVector();
                                GeoStyle supermapStyle = new GeoStyle();
                                SymbolizeToSuperMapSymbolLib(supermapStyle, supermapResource, pSymbol, simpleRender.Label);
                                supermapLayersettingVector.Style = supermapStyle;

                                map.Layers.Add(datasetVector, supermapLayersettingVector,false);
                                Layer SimpleRendererlayer = map.Layers[map.Layers.Count - 1];
                                SimpleRendererlayer.Caption = pLayer.Name;
                                IFeatureLayerDefinition2 featureLayerDefine = pFeatureLayer as IFeatureLayerDefinition2;
                                QueryParameter param = new QueryParameter();
                                param.AttributeFilter = featureLayerDefine.DefinitionExpression;
                                SimpleRendererlayer.DisplayFilter = param;
                               
                                layerList.Add(SimpleRendererlayer);
                            }
                            //点密度渲染
                            else if (featureRenderer is DotDensityRenderer)
                            {
                                Console.WriteLine("图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name);
                                Log(String.Format("Error:图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name));
                            }
                            //统计类的渲染器，类似于supermap饼图和柱状图
                            else if (featureRenderer is ChartRenderer)
                            {
                                Console.WriteLine("图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name);
                                Log(String.Format("Error:图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name));
                            }
                            else if (featureRenderer is ScaleDependentRenderer)
                            {
                                Console.WriteLine("图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name);
                                Log(String.Format("Error:图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name));
                            }
                            else if (featureRenderer is RepresentationRenderer)
                            {
                                Console.WriteLine("ProportionalSymbolRenderer，supermap中不支持改分段专题图");
                                Log(String.Format("Error:图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name));
                            }
                            else if (featureRenderer is ProportionalSymbolRenderer)
                            {
                                Console.WriteLine("图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name);
                                Log(String.Format("Error:图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name));
                            }
                            else
                            {
                                Console.WriteLine("图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name);
                                Log(String.Format("Error:图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name));
                            }
                        }
                        else if (pLayer is IRasterLayer)
                        {
                            //获取
                            IDataLayer2 dataLater = pLayer as IDataLayer2;
                            IDatasetName pDN = dataLater.DataSourceName as IDatasetName;

                            //根据arcgis类型创建supermaplayer
                            //避免名字转换冲突，事先判断

                            string workspaceName = pDN.WorkspaceName.BrowseName;
                            string workspacepath = pDN.WorkspaceName.PathName;

                            if (workspaceName == "Shapefile Data")
                            {
                                Console.WriteLine("使用的数据为shape file文件，请将文件导出到udb中使用，命名为 Shapefile Data ");
                                Log(String.Format("Error:图层 {0}使用的数据为shape file文件，请将文件导出到udb中使用，命名为 Shapefile Data ", pLayer.Name));
                            }

                            Datasets tempDatasets = null;
                            DatasourceConnectionInfo coninfo = new DatasourceConnectionInfo();
                            coninfo.Alias = workspaceName;
                            coninfo.Server = "./" + workspaceName + ".udb";
                            coninfo.EngineType = EngineType.UDB;
                            if (File.Exists("./" + workspaceName + ".udb"))
                            {

                                if (datasources.Contains(workspaceName))
                                {
                                    Datasource datasource = datasources[workspaceName];
                                    tempDatasets = datasource.Datasets;
                                }
                                else
                                {
                                    Datasource datasource = datasources.Open(coninfo);
                                    tempDatasets = datasource.Datasets;
                                }
                            }
                            else
                            {
                                Console.WriteLine(".......影像栅格图层没有关联数据，请指定，如果继续，将不会转换影像栅格图层........");
                                Log(String.Format("Error:图层 {0} 没有预先转换grid数据}.......影像栅格图层没有关联数据，请指定，如果没有，将不会转换影像栅格图层........\r\n", pLayer.Name));
                                continue;
                            }

                            Console.WriteLine("该图层为 RasterLayer 对应supermap 栅格图层 和 影像图层");
                            Log(String.Format("Info:该图层{0}为 RasterLayer 对应supermap 栅格图层 和 影像图层", pLayer.Name));
                            IRasterLayer pRasterLayer = (IRasterLayer)pLayer;
                            IRasterRenderer rasterRender = pRasterLayer.Renderer;

                            Dataset dataset = tempDatasets[pDN.Name];
                            if (dataset == null || dataset is DatasetImage)
                            {
                                if (dataset is DatasetImage)
                                {
                                    map.Layers.Add(dataset,true);
                                    Log(String.Format("Info:预转换的UDB中：图层： {0} 数据集： {1},为image，直接添加到地图", pLayer.Name, pDN.Name));
                                    continue;
                                }

                                Log(String.Format("Error:预转换的UDB中不存在rasterlayer： {0} 需要的 GRID数据集： {1},请检查转换的supermap数据集、", pLayer.Name, pDN.Name));
                                continue;
                            }
                            DatasetGrid grid = (DatasetGrid)dataset;

                            if (rasterRender is RasterUniqueValueRenderer)
                            {
                                ThemeGridUnique gridUnique = new ThemeGridUnique();
                                IRasterUniqueValueRenderer unique = rasterRender as IRasterUniqueValueRenderer;

                                if (unique.HeadingCount == 1)
                                {
                                    for (int m = 0; m < unique.ClassCount[0]; m++)
                                    {
                                        ThemeGridUniqueItem item = new ThemeGridUniqueItem();
                                        string label = unique.Label[0, m];
                                        ISymbol uniqueSymbol = unique.Symbol[0, m];
                                        object value = unique.Value[0, m, 0];
                                        if (value is double || value is Int32)
                                        {
                                            item.Unique = Convert.ToDouble(value);
                                        }
                                        if (uniqueSymbol is IFillSymbol)
                                        {
                                            IFillSymbol fillsymbol = uniqueSymbol as IFillSymbol;

                                            item.Color = ConvertToSystemColor(fillsymbol.Color);
                                        }

                                        item.Caption = label;
                                        gridUnique.Add(item);
                                        item.IsVisible = true;

                                    }

                                    string defaultLabel = unique.DefaultLabel;

                                    try
                                    {
                                        if (unique.DefaultSymbol != null)
                                        {
                                            ISymbol defaultSymbol = unique.DefaultSymbol;
                                            if (defaultSymbol is IFillSymbol)
                                            {
                                                IFillSymbol fillsymbol = defaultSymbol as IFillSymbol;

                                                gridUnique.DefaultColor = ConvertToSystemColor(fillsymbol.Color);
                                            }
                                        }
                                    }
                                    catch (System.Exception )
                                    {
                                        gridUnique.DefaultColor = Color.FromArgb(1, 0, 0, 0);
                                    }
                                }
                                else
                                {
                                    Console.WriteLine("HeadingCount 大于1  ,不支持这样的专题图类型");
                                    Log(String.Format("Warning:HeadingCount 大于1  ,不支持这样的专题图类型,图层名为 {0} ", pLayer.Name));
                                    continue;
                                }
                                themeList.Add(gridUnique);
                                map.Layers.Add(grid, gridUnique,false);
                                
                            }
                            else if (rasterRender is RasterClassifyColorRampRenderer)
                            {
                                IRasterClassifyColorRampRenderer classifyBreakRender = rasterRender as IRasterClassifyColorRampRenderer;
                                int classCount = classifyBreakRender.ClassCount;
                                double minValue = Double.MinValue;
                                ThemeGridRange supermapThemeGridRange = new ThemeGridRange();

                                for (int k = 0; k < classCount; k++)
                                {
                                    SuperMap.Mapping.ThemeGridRangeItem supermapThemeGridRangeitem = new SuperMap.Mapping.ThemeGridRangeItem();
                                    supermapThemeGridRangeitem.Caption = classifyBreakRender.Label[k];
                                    supermapThemeGridRangeitem.Start = minValue;
                                    supermapThemeGridRangeitem.End = classifyBreakRender.get_Break(k) + 0.0000001;
                                    minValue = supermapThemeGridRangeitem.End;

                                    ISymbol pSymbol = classifyBreakRender.Symbol[k];

                                    if (pSymbol is IFillSymbol)
                                    {
                                        IFillSymbol fillsymbol = pSymbol as IFillSymbol;
                                        if (fillsymbol is SimpleFillSymbol)
                                        {
                                            SimpleFillSymbol simple = fillsymbol as SimpleFillSymbol;
                                            supermapThemeGridRangeitem.Color = ConvertToSystemColor(simple.Color);
                                            supermapThemeGridRange.AddToTail(supermapThemeGridRangeitem);
                                        }
                                    }
                                    else
                                    {
                                        Console.WriteLine("改分段专题图为点符号分段，supermap中不支持该分段专题图");
                                        Log(String.Format("Error：该分段专题图为点符号分段，supermap中不支持改分段专题图,,图层名为 {0} ", pLayer.Name));
                                        //分段栅格专题图 
                                        Console.WriteLine("图层 {0} 中的栅格专题类型 RasterClassifyColorRampRenderer是supermap暂时不支持的", pLayer.Name);
                                        continue;
                                    }
                                }

                                themeList.Add(supermapThemeGridRange);
                                map.Layers.Add(grid, supermapThemeGridRange,false);
                               
                                //分段栅格专题图 
                            }
                            else if (rasterRender is RasterStretchColorRampRenderer)
                            {//普通图层

                                //supermap中只支持grid的专题图类型，所以影像都导入为栅格
                                //render values along color ramp
                                //int index = pRStretchRender.BandIndex;

                                IRasterStretchColorRampRenderer pRStretchRender = rasterRender as IRasterStretchColorRampRenderer;
                                //int classCount = pRStretchRender.ClassCount;

                                string colorscheme = pRStretchRender.ColorScheme;
                                IColorRamp colorRamp = pRStretchRender.ColorRamp;
                                LayerSettingGrid settingGrid = new LayerSettingGrid();
                                translateColorRamp(colorRamp, settingGrid, pLayer);

                                map.Layers.Add(grid, settingGrid,false);
                            }
                            else if (rasterRender is RasterColormapRenderer)
                            {
                                // The RasterColormapRenderer object displays raster data that has an existing colormap.
                                Console.WriteLine("图层 {0} 中的栅格专题类型RasterColormapRenderer 是supermap暂时不支持的", pLayer.Name);
                                Log(String.Format("Error：图层 {0} 中的栅格专题类型RasterColormapRenderer 是supermap暂时不支持的", pLayer.Name));

                            }
                            else if (rasterRender is RasterDiscreteColorRenderer)
                            {
                                Console.WriteLine("图层 {0} 中的栅格专题类型RasterDiscreteColorRenderer 是supermap暂时不支持的", pLayer.Name);
                                Log(String.Format("Error:图层 {0} 中的栅格专题类型RasterDiscreteColorRenderer 是supermap暂时不支持的", pLayer.Name));
                            }
                            else if (rasterRender is RasterRGBRenderer)
                            {
                                Console.WriteLine("图层 {0} 中的栅格专题类型RasterRGBRenderer 是supermap暂时不支持的", pLayer.Name);
                                Log(String.Format("Error:图层 {0} 中的栅格专题类型RasterRGBRenderer 是supermap暂时不支持的", pLayer.Name));
                            }
                        }
                        else
                        {
                            Console.WriteLine("该图层{0} 的类型，supermap中暂时不支持，请手动完成转换", pLayer.Name);
                            Log(String.Format("Error:该图层{0} 的类型，supermap中暂时不支持，请手动完成转换", pLayer.Name));
                        }
                    
                        pLayer = pEnumLayer.Next();
                    }

                    int count = map.Layers.Count;

                    string xml = map.ToXML();
                    maps.Add(pMap.Name, xml);
                }
                Console.WriteLine("解析完成 MXD中地图图层信息");

            }
            else
            {
                Console.WriteLine("错误的mxd文档，请重新指定");
                Console.ReadKey();
            }

            ///////////////////////////////////////////////////////////////////
            //使用supermap打开工作空间

            Console.WriteLine("稍等。正在保存工作空间........");
       
            m_workspace.Save();
            
            map.Dispose();
            m_workspace.Dispose();
			Console.WriteLine("Info:工作空间输出路径为：{0}\r\n", System.IO.Directory.GetCurrentDirectory());
            Log(String.Format("Info:工作空间输出路径为：{0}\r\n", System.IO.Directory.GetCurrentDirectory()));
        }

        public static void convertToGroupLayer(IGroupLayer iGrouplayer, LayerGroup superMapLayerGroup,
            Datasets supermapDatasets, Datasources datasources,
            IEnumLayer pEnumLayer, Resources supermapResource,
             List<Layer> layerList, List<Theme> themeList)
        {
            ICompositeLayer pCompositeLayer = iGrouplayer as ICompositeLayer;
            int groupLayerCount = pCompositeLayer.Count;
            DatasetVector datasetVector = null;

            for (int i = 0; i < groupLayerCount; i++)
            {
                ILayer pLayer = pCompositeLayer.get_Layer(i);
                pEnumLayer.Next();

                if (pLayer is GroupLayer)
                {
                    Console.WriteLine("该图层为 GroupLayer 对应supermap 分组图层");
                    Log(String.Format("Info:该子图层:<{0}>为 GroupLayer 对应supermap 分组图层",pLayer.Name));
                    IGroupLayer pGrouplayer = (IGroupLayer)pLayer;
                    LayerGroup supermapLG = new LayerGroup(pGrouplayer.Name);
                    superMapLayerGroup.Add(supermapLG);
                    layerList.Add(supermapLG);
                    convertToGroupLayer(pGrouplayer, supermapLG, supermapDatasets, datasources, pEnumLayer,
                        supermapResource,
                        layerList, themeList);

                    Console.WriteLine("成功将esri GroupLayer存入supermap分组图层");
                    Log(String.Format("Info:成功将分组图层:<{0}> 转换为 supermap 分组图层", pLayer.Name));
                }
                else if (pLayer is FeatureLayer)
                {
                    Console.WriteLine("该图层为 FeatureLayer 对应supermap 矢量图层 和 专题图层");
                    Log(String.Format("Info:开始转换图层:<{0}>，FeatureLayer 对应supermap 矢量图层 和 专题图层", pLayer.Name));
                    //通过featurelayer获得geofeaturelayer
                    IFeatureLayer2 pFeatureLayer = pLayer as IFeatureLayer2;
                    IGeoFeatureLayer geolayer = pFeatureLayer as IGeoFeatureLayer;
                    if (geolayer == null)
                    {
                        continue;
                    }

                    IFeatureRenderer featureRenderer = geolayer.Renderer;

                    //获取
                    IDataLayer2 dataLater = pFeatureLayer as IDataLayer2;
                    IDatasetName pDN = dataLater.DataSourceName as IDatasetName;

                    //根据arcgis类型创建supermaplayer
                    esriGeometryType type = pFeatureLayer.ShapeType;
                    DatasetVectorInfo vectorInfo = null;

                    //避免名字转换冲突，事先判断

                    string workspaceName = pDN.WorkspaceName.BrowseName;
                    string workspacepath = pDN.WorkspaceName.PathName;

                    if (workspaceName == "Shapefile Data")
                    {
                        Console.WriteLine("使用的数据为shape file文件，请将文件导出到udb中使用，命名为 Shapefile Data ");
                    }

                    Datasets datasets = null;
                    DatasourceConnectionInfo coninfo = new DatasourceConnectionInfo();
                    coninfo.Alias = workspaceName;
                    coninfo.Server = "./" + workspaceName + ".udb";
                    coninfo.EngineType = EngineType.UDB;
                    Datasource datasource = null;
                    if (File.Exists("./" + workspaceName + ".udb"))
                    {                     
                        if (datasources.Contains(workspaceName))
                        {
                            datasource = datasources[workspaceName];
                            datasets = datasource.Datasets;
                        }
                        else
                        {
                            datasource = datasources.Open(coninfo);
                            datasets = datasource.Datasets;
                        }                   
                    }
                    else
                    {
                        datasource = datasources.Create(coninfo);
                        datasets = datasource.Datasets;
                    }

                    string datasetNameSrc = pDN.Name;
                    ConvertArcgisFeatureClassData(workspacepath, datasetNameSrc, workspaceName, datasources);        
                    if (datasetNameSrc.Length >= 30)
                    {
                        datasetNameSrc = datasetNameSrc.Substring(0, 27);
                    }

                    string datasetNameDes = datasetNameSrc;
                   
                    try
                    {
                        datasetNameDes = datasetNameDes.Replace("-", "");
                        Convert.ToInt32(datasetNameDes.Substring(0,1)); 
                        datasetNameDes = "T" + datasetNameDes;
                    }
                    catch(Exception )
                    {

                    }

                    if (type == esriGeometryType.esriGeometryPoint)
                    {
                        vectorInfo = new DatasetVectorInfo(datasetNameDes, DatasetType.Point);
                    }
                    else if (type == esriGeometryType.esriGeometryLine || type == esriGeometryType.esriGeometryPolyline)
                    {
                        vectorInfo = new DatasetVectorInfo(datasetNameDes, DatasetType.Line);
                    }
                    else if (type == esriGeometryType.esriGeometryPolygon)
                    {
                        vectorInfo = new DatasetVectorInfo(datasetNameDes, DatasetType.Region);
                    }
                    else
                    {
                        vectorInfo = new DatasetVectorInfo(datasetNameDes, DatasetType.Point);
                    }

                    if (datasets.Contains(pDN.Name))
                    {
                        datasetVector = datasets[pDN.Name] as DatasetVector;
                    }
                    else if (datasets.Contains(datasetNameDes))
                    {
                        Log(String.Format("该图层中数据文件名称太长，supermap不支持，名称：<{0}>，被截断为<{1}>", pDN.Name, datasetNameDes));
                        datasetVector = datasets[datasetNameDes] as DatasetVector;
                    }
                    else
                    {

                        //创建图层，解析图层基本信息
                        datasetVector = datasets.Create(vectorInfo);
                    }


                    IAnnotateLayerPropertiesCollection annotateLayerPropertiesCollection = geolayer.AnnotationProperties;
                    //解析mxd图层中的标签
                    Console.WriteLine("解析mxd图层中的标签，MXD的一个图层中可以由一个或多个字段生成多个子层，类似于superma的多个标签专题图");
                    Log("Info:解析mxd图层中的标签，MXD的一个图层中可以由一个或多个字段生成多个子层，类似于superma的多个标签专题图");

                    esriGeometryType type1 = pFeatureLayer.ShapeType;
                    for (int k = 0; k < annotateLayerPropertiesCollection.Count; k++)
                    {
                        IAnnotateLayerProperties Item;
                        IElementCollection placedElements;
                        IElementCollection unplacedElements;
                        annotateLayerPropertiesCollection.QueryItem(k, out Item, out placedElements, out unplacedElements);

                        LabelEngineLayerProperties labelproperty = Item as LabelEngineLayerProperties;
                        ILabelEngineLayerProperties2 ilabelproperty = labelproperty as ILabelEngineLayerProperties2;
                        IOverposterLayerProperties iOverposterLayerProperties = ilabelproperty.OverposterLayerProperties;
                        //                         //IBasicOverposterLayerProperties iBasicOverposterLayerProperties = ilabelproperty.BasicOverposterLayerProperties;
                        MaplexLabelEngineLayerProperties maplexLabelEngine = ilabelproperty as MaplexLabelEngineLayerProperties;

                        string labelpression = ilabelproperty.Expression;
                        bool flag = ilabelproperty.IsExpressionSimple;
                        ITextSymbol iTextSymbol = ilabelproperty.Symbol;
                        
                        ThemeLabel supermapThemelabel = new ThemeLabel();

                        labelpression = labelpression.Substring(1, labelpression.Length - 2);

                        if (ilabelproperty.IsExpressionSimple == false)
                        {
                            Console.WriteLine("图层  {0}  中，存在supermap无法识别的标签专题图字段 {1},该字段为复杂字段，supermap中不支持", pLayer.Name, ilabelproperty.Expression);
                            Log(String.Format("Warning:图层  {0}  中，存在supermap无法识别的标签专题图字段 {1},该字段为复杂字段，supermap中不支持", pLayer.Name, ilabelproperty.Expression));
                            labelpression = null;
                        }
                        else if (labelpression.Contains("[") || labelpression.Contains("]"))
                        {
                            Console.WriteLine("图层  {0}  中，存在supermap无法识别的标签专题图字段 {1}", pLayer.Name, ilabelproperty.Expression);
                            Log(String.Format("Warning:图层  {0}  中，存在supermap无法识别的标签专题图字段 {1}", pLayer.Name, ilabelproperty.Expression));
                            labelpression = null;
                        }

                        supermapThemelabel.LabelExpression = labelpression;
                        TextStyle supermaptextStyle = new TextStyle();

                        //文字风格 
                        IFormattedTextSymbol formattedsymbol = iTextSymbol as IFormattedTextSymbol;
                        stdole.IFontDisp fontDisp = iTextSymbol.Font;

                        TextSymbol textSymbol = iTextSymbol as TextSymbol;
                        IMask mask = textSymbol as IMask;
                        IFillSymbol maskFillSymbol = mask.MaskSymbol;

                        supermaptextStyle.Bold = fontDisp.Bold;
                        supermaptextStyle.FontName = fontDisp.Name;
                        supermaptextStyle.Italic = fontDisp.Italic;
                        supermaptextStyle.Underline = fontDisp.Underline;
                        supermaptextStyle.Strikeout = fontDisp.Strikethrough;

                        if (formattedsymbol.ShadowXOffset != 0 || formattedsymbol.ShadowYOffset != 0)
                        {
                            Log(String.Format("Warning:图层  {0}  中存在文字阴影，supermap对文字阴影的支持比较简洁,不够完善", pLayer.Name));
                            supermaptextStyle.Shadow = true;
                        }


                        if (type == esriGeometryType.esriGeometryPoint)
                        {
                            //访问maplex标注引擎
                            IMaplexOverposterLayerProperties pMaplexPro = iOverposterLayerProperties as IMaplexOverposterLayerProperties;

                            esriMaplexPointPlacementMethod method = esriMaplexPointPlacementMethod.esriMaplexSoutheastOfPoint;
                            //仅针对点图层设置对其方式
                            if (pMaplexPro != null)
                            {
                                method = pMaplexPro.PointPlacementMethod;
                            }

                            //该值为标注的优先级设定
                            //IPointPlacementPriorities properties = pMaplexPro.PointPlacementPriorities;
                            if (method == esriMaplexPointPlacementMethod.esriMaplexSoutheastOfPoint)
                            {
                                supermaptextStyle.Alignment = TextAlignment.TopLeft;
                            }
                            else if (method == esriMaplexPointPlacementMethod.esriMaplexSouthOfPoint)
                            {
                                supermaptextStyle.Alignment = TextAlignment.TopCenter;
                            }
                            else if (method == esriMaplexPointPlacementMethod.esriMaplexSouthwestOfPoint)
                            {
                                supermaptextStyle.Alignment = TextAlignment.TopRight;
                            }
                            else if (method == esriMaplexPointPlacementMethod.esriMaplexNortheastOfPoint)
                            {
                                supermaptextStyle.Alignment = TextAlignment.BottomLeft;
                            }
                            else if (method == esriMaplexPointPlacementMethod.esriMaplexNorthOfPoint)
                            {
                                supermaptextStyle.Alignment = TextAlignment.BottomCenter;
                            }
                            else if (method == esriMaplexPointPlacementMethod.esriMaplexNorthwestOfPoint)
                            {
                                supermaptextStyle.Alignment = TextAlignment.BottomRight;
                            }
                            else if (method == esriMaplexPointPlacementMethod.esriMaplexCenteredOnPoint)
                            {
                                supermaptextStyle.Alignment = TextAlignment.MiddleCenter;
                            }
                            else if (method == esriMaplexPointPlacementMethod.esriMaplexWestOfPoint)
                            {
                                supermaptextStyle.Alignment = TextAlignment.MiddleRight;
                            }
                            else if (method == esriMaplexPointPlacementMethod.esriMaplexEastOfPoint)
                            {
                                supermaptextStyle.Alignment = TextAlignment.MiddleLeft;
                            }
                            else
                            {
                                supermaptextStyle.Alignment = TextAlignment.TopLeft;
                            }
                        }

                        decimal deci = fontDisp.Size;
                        //arcmap中单位好像和supermap对不上
                        supermaptextStyle.FontHeight = (iTextSymbol.Size + 3) * 25.4 / 72; //Convert.ToInt16(deci);
                        supermaptextStyle.Weight = fontDisp.Weight;
                        IColor iColor = iTextSymbol.Color;
                        
                        supermaptextStyle.Outline = (int)(mask.MaskSize * 25.4 / 72) == 0.0 ? false : true;
                        if (iTextSymbol.Size > 10)
                        {
                            supermaptextStyle.OutlineWidth = (int)mask.MaskSize;
                        }
                        if (mask.MaskSymbol != null)
                        {
                            supermaptextStyle.BackColor = ConvertToSystemColor(mask.MaskSymbol.Color);
                        }
                        else
                        {
                            supermaptextStyle.BackColor = Color.FromArgb(255, 255, 255, 255);
                        }


                        supermaptextStyle.ForeColor = ConvertToSystemColor(iColor);
                        supermapThemelabel.UniformStyle = supermaptextStyle;

                        superMapLayerGroup.Layers.Add(datasetVector, supermapThemelabel,true);
                        Layer layer = superMapLayerGroup.Layers[0];
                        themeList.Add(supermapThemelabel);
                        if (Item.Class == "Default" && annotateLayerPropertiesCollection.Count == 1)
                        {
                            layer.Caption = pLayer.Name;
                        }
                        else
                        {
                            layer.Caption = Item.Class;
                        }
                        layer.IsVisible = geolayer.DisplayAnnotation;
                        layer.MaxVisibleScale = Item.AnnotationMaximumScale;
                        layer.MinVisibleScale = Item.AnnotationMinimumScale;
                        QueryParameter param = new QueryParameter();

                        param.AttributeFilter = Item.WhereClause;
                        layer.DisplayFilter = param;
                       
                        layerList.Add(layer);
                    }


                    //单值渲染器
                   if (featureRenderer is UniqueValueRenderer)
                    {
                        //该图层为单值渲染图层 
                        ThemeUnique supermapThemeuniqu = new ThemeUnique();


                        IUniqueValueRenderer uniqueRender = featureRenderer as IUniqueValueRenderer;
                        int fieldCount = uniqueRender.FieldCount;
                        int valueCount = uniqueRender.ValueCount;


                        string fieldString = "";
                        if (fieldCount > 1)
                        {
                            //如果多个字段为数值，会导致数值相加
                            Console.WriteLine("mxd中采用的多字段控制单值，supermap对此支持不完全");
                            Log(String.Format("Error:采用的多字段控制单值，supermap对此支持不完全,图层：{0}，分组为{1} ",pLayer.Name,iGrouplayer.Name));
                        }
                        for (int k = 0; k < fieldCount; k++)
                        {
                            fieldString += uniqueRender.Field[0];
                        }

                        supermapThemeuniqu.UniqueExpression = uniqueRender.Field[0];

                        Log("Warning:mxd中采用多个单值指定为一个单值项，supermap中只能采用将某些单值项指定为相同的符号来实现");
                        Console.WriteLine("mxd中采用多个单值指定为一个单值项，supermap中只能采用将某些单值项指定为相同的符号来实现");
                        GeoStyle supermapGeoStyle = new GeoStyle();
                        for (int m = 0; m < valueCount; m++)
                        {
                            ThemeUniqueItem supermapThemeitem = new ThemeUniqueItem();
                            
                            string uniqueVal = uniqueRender.get_Value(m);
                            ISymbol pSymbol = uniqueRender.get_Symbol(uniqueVal);

                            supermapThemeitem.Caption = uniqueRender.get_Label(uniqueVal);
                            supermapThemeitem.IsVisible = true;//esri中没有根据每个段的可见性设置
                            supermapThemeitem.Unique = uniqueVal;
                            if (pSymbol == null)
                            {
                                supermapThemeitem.Style = supermapGeoStyle;
                                supermapThemeuniqu.Add(supermapThemeitem);
                                continue;
                            }

                            SymbolizeToSuperMapSymbolLib(supermapGeoStyle, supermapResource, pSymbol, supermapThemeitem.Caption);
                            supermapThemeitem.Style = supermapGeoStyle;
                            supermapThemeuniqu.Add(supermapThemeitem);
                        }

                        ISymbol defaultSymbol = uniqueRender.DefaultSymbol;
                        Boolean isDisplayDefault = uniqueRender.UseDefaultSymbol;
                        GeoStyle geoStyle = new GeoStyle();
                        SymbolizeToSuperMapSymbolLib(geoStyle, supermapResource, defaultSymbol, "other Values");
                        supermapThemeuniqu.DefaultStyle = geoStyle;
                        supermapThemeuniqu.IsDefaultStyleVisible = isDisplayDefault;

                     
                        superMapLayerGroup.Layers.Add(datasetVector, supermapThemeuniqu, false);
                        Layer uniqueRendererlayer = superMapLayerGroup.Layers[superMapLayerGroup.Layers.Count - 1];
                        
                        uniqueRendererlayer.MinVisibleScale = pLayer.MinimumScale;
                        uniqueRendererlayer.MaxVisibleScale = pLayer.MaximumScale;
                        uniqueRendererlayer.Caption = pLayer.Name;
                        themeList.Add(supermapThemeuniqu);

                        IFeatureLayerDefinition2 featureLayerDefine = pFeatureLayer as IFeatureLayerDefinition2;
                        QueryParameter param = new QueryParameter();
                        param.AttributeFilter = featureLayerDefine.DefinitionExpression;
                        uniqueRendererlayer.DisplayFilter = param;

                        
                        layerList.Add(uniqueRendererlayer);
                    }
                    //A renderer that can be used to draw graduated color (choropleth) and graduated symbol maps.
                    else if (featureRenderer is ClassBreaksRenderer)
                    {
                        IClassBreaksRenderer classBrakRender = featureRenderer as ClassBreaksRenderer;
                        string displayField = classBrakRender.Field;
                        string normalizeField = classBrakRender.NormField;
                        int breakcount = classBrakRender.BreakCount;
                        SuperMap.Mapping.ThemeRange supermapThemeRange = new SuperMap.Mapping.ThemeRange();
                        //supermapThemeRange.RangeMode = RangeMode.CustomInterval;
                        supermapThemeRange.RangeExpression = displayField;
                        supermapThemeRange.Precision = 0.0000001;

                        themeList.Add(supermapThemeRange);
                        Double minValue = Double.MinValue;
                        
                        //判断如果不是填充类型就失败
                        ISymbol ptempSymbol = classBrakRender.Symbol[0];                       
                        if(ptempSymbol is IFillSymbol)
                        {

                        }
                        else
                        {
                            Console.WriteLine("改分段专题图为点符号分段，supermap中不支持改分段专题图");
                            Log("Error:改分段专题图为点符号分段，supermap中不支持改分段专题图");
                            continue;
                        }


                        for (int k = 0; k < breakcount; k++)
                        {
                            SuperMap.Mapping.ThemeRangeItem supermapThemeitem = new SuperMap.Mapping.ThemeRangeItem();
                            supermapThemeitem.Caption = classBrakRender.Label[k];
                            supermapThemeitem.Start = minValue;
                            supermapThemeitem.End = classBrakRender.get_Break(k) + 0.0000001;
                            minValue = supermapThemeitem.End;

                            ISymbol pSymbol = classBrakRender.Symbol[k];

                            if (pSymbol is IFillSymbol)
                            {
                                GeoStyle supermapGeoStyle = new GeoStyle();
                                SymbolizeToSuperMapSymbolLib(supermapGeoStyle, supermapResource, pSymbol, supermapThemeitem.Caption);
                                supermapThemeitem.Style = supermapGeoStyle;
                                supermapThemeRange.AddToTail(supermapThemeitem);
                            }
                            else
                            {
                                Console.WriteLine("改分段专题图为点符号分段，supermap中不支持改分段专题图");
                                Log("Error:改分段专题图为点符号分段，supermap中不支持改分段专题图");
                                continue;
                            }
                        }
                        superMapLayerGroup.Layers.Add(datasetVector, supermapThemeRange,false);
                        Layer rangeRendererlayer = superMapLayerGroup.Layers[superMapLayerGroup.Layers.Count -1];
                        rangeRendererlayer.Caption = pLayer.Name;
                        IFeatureLayerDefinition2 featureLayerDefine = pFeatureLayer as IFeatureLayerDefinition2;
                        QueryParameter param = new QueryParameter();
                        param.AttributeFilter = featureLayerDefine.DefinitionExpression;
                        rangeRendererlayer.DisplayFilter = param;
                        
                    }
                    //简单渲染器，统一风格
                    //简单专题图就是supermap的普通图层
                    else if (featureRenderer is SimpleRenderer)
                    {
                        SimpleRenderer simpleRender = featureRenderer as SimpleRenderer;
                        ISymbol pSymbol = simpleRender.Symbol;

                        LayerSettingVector supermapLayersettingVector = new LayerSettingVector();
                        GeoStyle supermapStyle = new GeoStyle();
                        SymbolizeToSuperMapSymbolLib(supermapStyle, supermapResource, pSymbol, simpleRender.Label);
                        supermapLayersettingVector.Style = supermapStyle;


                        superMapLayerGroup.Layers.Add(datasetVector, supermapLayersettingVector,false);
                        Layer SimpleRendererlayer = superMapLayerGroup.Layers[superMapLayerGroup.Layers.Count - 1];
                        SimpleRendererlayer.Caption = pLayer.Name;
                        IFeatureLayerDefinition2 featureLayerDefine = pFeatureLayer as IFeatureLayerDefinition2;
                        QueryParameter param = new QueryParameter();
                        param.AttributeFilter = featureLayerDefine.DefinitionExpression;
                        SimpleRendererlayer.DisplayFilter = param;

                        layerList.Add(SimpleRendererlayer);
                    }
                    //点密度渲染
                    else if (featureRenderer is DotDensityRenderer)
                    {
                        Console.WriteLine("图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name);
                        Log(String.Format("Error:图层 {0} 中的专题类型 是supermap暂时不支持的,对应分组：{1}", pLayer.Name,iGrouplayer.Name));
                    }
                    //统计类的渲染器，类似于supermap饼图和柱状图
                    else if (featureRenderer is ChartRenderer)
                    {
                        Console.WriteLine("图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name);
                        Log(String.Format("Error:图层 {0} 中的专题类型 是supermap暂时不支持的,对应分组：{1}", pLayer.Name,iGrouplayer.Name));
                    }
                    else if (featureRenderer is ScaleDependentRenderer)
                    {
                        Console.WriteLine("图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name);
                        Log(String.Format("Error:图层 {0} 中的专题类型 是supermap暂时不支持的,对应分组：{1}", pLayer.Name,iGrouplayer.Name));
                    }
                    else if (featureRenderer is RepresentationRenderer)
                    {
                        IDataLayer2 dataLayer = pLayer as IDataLayer2;
                        IDatasetName pDataName = dataLater.DataSourceName as IDatasetName;

                        string workName = pDataName.WorkspaceName.BrowseName;
                        string workpath = pDataName.WorkspaceName.PathName;
                        String extension = System.IO.Path.GetExtension(workpath);
                        IRepresentationWorkspaceExtension pRepresentationWorkspaceExtension = null;
                        
                        if (extension.ToUpper() == ".GDB")
                        {
                            //这是用的最多的一种方式,如果是FileGeodatabasse,则将

                            FileGDBWorkspaceFactory GDBWSF = new FileGDBWorkspaceFactory();
                            IWorkspace workspace = GDBWSF.OpenFromFile(workpath, 0);
                            IWorkspaceExtensionManager workspaceExtensionManager = (IWorkspaceExtensionManager)workspace;


                            for (int f = 0; f < workspaceExtensionManager.ExtensionCount; f++)
                            {
                                IWorkspaceExtension workspaceExtension = workspaceExtensionManager.get_Extension(f);

                                pRepresentationWorkspaceExtension = workspaceExtension as IRepresentationWorkspaceExtension;

                                if (pRepresentationWorkspaceExtension != null)
                                {
                                    IFeatureClass featureclass = null;
                                    pRepresentationWorkspaceExtension.get_FeatureClassHasRepresentations(featureclass);
                                    IEnumDatasetName enumDatasetName = pRepresentationWorkspaceExtension.RepresentationClassNames;
                                    int num = 0;
                                    enumDatasetName.Reset();
                                    while(true)
                                    {
                                        num++;
                                        IDatasetName datasetName = enumDatasetName.Next();

                                        if (datasetName == null)
                                        {
                                            break;
                                        }

                                     
                                    }
                                   
                                }

                            }                            
                        }
//                         else if (extension.ToUpper() == ".MDB")
//                         {
//                             //ArcEngine中个人数据库为Access。
//                             AccessWorkspaceFactory AWSF = new AccessWorkspaceFactoryClass();
// 
//                             pRepresentationWorkspaceExtension = AWSF.OpenFromFile(workpath, 0) as IRepresentationWorkspaceExtension;
//                         }
                        else
                        {
                            Console.WriteLine("{0}:暂时不支持的数据库类型", extension.ToUpper());
                        }

                        IGeoFeatureLayer pGeoFeatureLayer = pFeatureLayer as IGeoFeatureLayer;
                        //如不能转换返回
                        IDataset pDataset = pFeatureLayer as IDataset;
                        IWorkspace pWorkspace = pDataset.Workspace;
                        if (pWorkspace.Type == esriWorkspaceType.esriFileSystemWorkspace)
                        {
                            //return null; ;
                        }
                        //创建表达类时应停止编辑进程
                        IWorkspaceEdit pWksEdit = pWorkspace as IWorkspaceEdit;
                        if (pWksEdit.IsBeingEdited())
                        {
                            pWksEdit.StopEditOperation();
                            pWksEdit.StopEditing(true);
                        }

                        IRepresentationRenderer representationRenderer = featureRenderer as IRepresentationRenderer;
                        IRepresentationClass representationClass = representationRenderer.RepresentationClass;

                        IFeatureClass featureClass = pFeatureLayer.FeatureClass;
                        ESRI.ArcGIS.Geodatabase.ISpatialFilter spatialFilter = new ESRI.ArcGIS.Geodatabase.SpatialFilterClass();
                        spatialFilter.Geometry = featureClass.Extension as IGeometry;
                        IFeatureCursor featureCursor = featureClass.Search(spatialFilter, false);
                        int count = featureClass.FeatureCount(spatialFilter);
                        IMapContext mapContext = new MapContext();
                        mapContext.Init(pReference,1/125000000.0,featureClass.Extension as  IEnvelope);
                                                                      
                        IRepresentationRules rules = representationClass.RepresentationRules;

                        IRepresentationRule rule = new RepresentationRule();
                        rules.Reset();

                        while (true)
                        {
                            int id;
                            
                            rules.Next(out id, out rule);
                            if (rule == null)
                            {
                                break;
                            }

                            string name = rules.get_Name(id);

                            int layerCount = rule.LayerCount;



                            while (true)
                            {
                                IFeature feature = featureCursor.NextFeature();

                                if (feature == null)
                                {
                                    break;
                                }

                                IRepresentation Rep = representationClass.GetRepresentation(feature, mapContext);

                                IRepresentationGraphics newRepresentationGraphics = new RepresentationGraphics();

                                if (Rep.Graphics != null)
                                {
                                    newRepresentationGraphics = Rep.Graphics;
                                    newRepresentationGraphics.ResetGeometry();
                                    newRepresentationGraphics.Reset();
                                    int num = 0;
                                    IGeometry pgeometry1 = null;
                                    IGeometry pgeometry2 = null;
                                    IGeometry shape = Rep.Shape;
                                    IGeometry shape1 = Rep.ShapeCopy;
                                    IGeometry shape2 = Rep.ShapeEdit;
                                    IGeometry feature1 = Rep.Feature.Shape;
                                    IRepresentationRule rule1 = null;

                                    newRepresentationGraphics.Next(out  pgeometry1,out rule1);
                                    newRepresentationGraphics.NextGeometry(out num, out pgeometry2);

                                    continue;
                                }
                                else
                                {
                                    Rep.Graphics = newRepresentationGraphics;

                                    Rep.UpdateFeature();

                                    IGeometry pgeometry1 = new PolylineClass();

                                    IRepresentationRule rule2 = new RepresentationRule();

                                    int myid = 0;
                                    //
                                    Rep.Graphics.ResetGeometry();
                                    Rep.Graphics.Reset();

                                    Rep.Graphics.Add(Rep.Shape, rule);

                                    Rep.Graphics.NextGeometry(out myid, out pgeometry1);
                                    Rep.Graphics.Add(pgeometry1, rule);

                                    IGeometry gg = mapContext.FromGeographyToMap(pgeometry1);

                                    Rep.UpdateFeature();
                                    feature.Store();
                                }
                                

                                

                                IGeometry pgeometry = Rep.ShapeEdit;
                                if (pgeometry.GeometryType == esriGeometryType.esriGeometryPolyline)
                                {
                                    IPolyline polyline = pgeometry as IPolyline;

                                }
                                else if (pgeometry.GeometryType == esriGeometryType.esriGeometryPolygon)
                                {
                                    IPolygon polygon = pgeometry as IPolygon;
                                }

                                //pgraphics.
                            }

                            //全局制图表达效果
                            IGeometricEffects pGeometricEffectsGlobal = rule as IGeometricEffects;


                            AnalyseEffects(pGeometricEffectsGlobal);

                            for (int p = 0; p < layerCount; p++ )
                            {
                                IBasicSymbol basicSymbol = rule.Layer[p];

                                IBasicFillSymbol basicFillsymbol = basicSymbol as IBasicFillSymbol;
  
                                IBasicLineSymbol basicLineSymbol = basicSymbol as IBasicLineSymbol;

                                IBasicMarkerSymbol basicMarkerSymbol = basicSymbol as IBasicMarkerSymbol;


                                if (basicFillsymbol != null)
                                {
                                    IFillPattern pattern = basicFillsymbol.FillPattern;
                                    IGraphicAttributes graphicAttribute = pattern as IGraphicAttributes;

                                    if (graphicAttribute.GraphicAttributeCount == 7)
                                    {                                       
                                        IColor color1 = (IColor)graphicAttribute.get_Value(0);
                                        IColor color2 = (IColor)graphicAttribute.get_Value(1);
                                        esriSimpleFillStyle  patternstlyle  =  (esriSimpleFillStyle)graphicAttribute.get_Value(2);
                                        int intelvsCount = (int)graphicAttribute.get_Value(3);
                                        double percent = (double)graphicAttribute.get_Value(4);
                                        object algorithm = graphicAttribute.get_Value(5);
                                        double angle = (double)graphicAttribute.get_Value(6);
                                    }
                                    else if (graphicAttribute.GraphicAttributeCount == 5)
                                    {
                                        IColor color1 = (IColor)graphicAttribute.get_Value(0);
                                        double with = (double)graphicAttribute.get_Value(1);
                                        double angle = (double)graphicAttribute.get_Value(2);
                                        double step = (double)graphicAttribute.get_Value(3);
                                        double offset = (double)graphicAttribute.get_Value(4);
                                    }
                                    else if (graphicAttribute.GraphicAttributeCount == 1)
                                    {
                                        IColor color1 = (IColor)graphicAttribute.get_Value(0);
                                    }

                                    //各个制图表达层的制图效果
                                    IGeometricEffects pGeometricEffects = basicFillsymbol as IGeometricEffects;
                                    
                                    
                                    IGeometricEffect pGeometricEffect = new GeometricEffectCut();

                                    object gg = graphicAttribute.Value[0];
                                }
                                else if (basicLineSymbol != null)
                                {

                                    ILineStroke stroke = basicLineSymbol.Stroke;

                                    IGraphicAttributes graphicAttribute = stroke as IGraphicAttributes;

                                    double with = (double)graphicAttribute.get_Value(0);
                                    esriLineCapStyle lineCaps = (esriLineCapStyle)graphicAttribute.get_Value(1);
                                    esriLineJoinStyle linejoins = (esriLineJoinStyle)graphicAttribute.get_Value(2);
                                    IColor icolor = (IColor)graphicAttribute.get_Value(3);


                                    IGeometricEffects pGeometricEffects = basicLineSymbol as IGeometricEffects;
                                    AnalyseEffects(pGeometricEffects);                 
                                    
                                }
                                else if (basicMarkerSymbol != null)
                                {
                                    IMarkerPlacement placement = basicMarkerSymbol.MarkerPlacement;
                                    IGraphicAttributes graphicAttribute = basicMarkerSymbol as IGraphicAttributes;

                                    IRepresentationMarker makerSymbol = (IRepresentationMarker)graphicAttribute.get_Value(1);
                                    double size = (double)graphicAttribute.get_Value(2);    //'Define size of marker.
                                    double angle = (double)graphicAttribute.get_Value(3);   //'Define angle of marker.
                                   
                                    if (placement is MarkerPlacementAlongLine)
                                    {

                                        MarkerPlacementAlongLine alongline = placement as MarkerPlacementAlongLine;
                                        IGraphicAttributes alonglineAttribute = alongline as IGraphicAttributes;

                                        int lineStep = (int)alonglineAttribute.get_Value(0);
                                        int lineEnds = (int)alonglineAttribute.get_Value(1);
                                        //待续
                                    }
                                    else if (placement is MarkerPlacementAtExtremities)
                                    {
                                       
                                    }
                                    else if (placement is MarkerPlacementDecoration)
                                    {
                                       
                                    }
                                    else if (placement is MarkerPlacementInsidePolygon)
                                    {
                                        
                                    }
                                    else if (placement is MarkerPlacementOnLine)
                                    {
                                      
                                    }
                                    else if (placement is MarkerPlacementOnPoint)
                                    {
                                    }
                                    else if (placement is MarkerPlacementPolygonCenter)
                                    {
                                    }
                                    else if (placement is MarkerPlacementRandomAlongLine)
                                    {
                                    }
                                    else if (placement is MarkerPlacementRandomInPolygon)
                                    {

                                    }
                                    else if (placement is MarkerPlacementVariableAlongLine)
                                    {
                                    }

                                    IGeometricEffects pGeometricEffects = basicMarkerSymbol as IGeometricEffects;
                                    

                                    AnalyseEffects(pGeometricEffects);

                                                        
                                 
                                }





                            }



                        }
                        

                    }
                    else if (featureRenderer is ProportionalSymbolRenderer)
                    {
                        Console.WriteLine("图层 {0} 中的专题类型 ProportionalSymbolRenderer是supermap暂时不支持的", pLayer.Name);
                        Log(String.Format("Error:图层 {0} 中的专题类型 是supermap暂时不支持的,对应分组：{1}", pLayer.Name,iGrouplayer.Name));
                    }
                   
                    else
                    {
                        Console.WriteLine("图层 {0} 中的专题类型 是supermap暂时不支持的", pLayer.Name);
                        Log(String.Format("Error:图层 {0} 中的专题类型 是supermap暂时不支持的,对应分组：", pLayer.Name,iGrouplayer.Name));
                    }

                    Log(String.Format("Info:成功将图层:<{0}> 转换为 supermap 图层", pLayer.Name));
                }
                else if (pLayer is IRasterLayer)
                {
                    Log(String.Format("\r\nInfo:开始转换图层:<{0}>，RasterLayer 对应supermap 栅格 和 影像图层", pLayer.Name));
                    //获取
                    IDataLayer2 dataLater = pLayer as IDataLayer2;
                    IDatasetName pDN = dataLater.DataSourceName as IDatasetName;

                    //根据arcgis类型创建supermaplayer
                    //避免名字转换冲突，事先判断

                    string workspaceName = pDN.WorkspaceName.BrowseName;
                    string workspacepath = pDN.WorkspaceName.PathName;

                    if (workspaceName == "Shapefile Data")
                    {
                        Console.WriteLine("使用的数据为shape file文件，请将文件导出到udb中使用，命名为 Shapefile Data ");
                        Log(String.Format("Warning:图层 {0}使用的数据为shape file文件，请将文件导出到udb中使用，命名为 Shapefile Data ",pLayer.Name));
                    }
                    string datasetNameSrc = pDN.Name;
                    ConvertArcgisRasterData(workspacepath, datasetNameSrc, workspaceName, datasources);

                    Datasets datasets = null;
                    DatasourceConnectionInfo coninfo = new DatasourceConnectionInfo();
                    coninfo.Alias = workspaceName;
                    coninfo.Server = "./" + workspaceName + ".udb";
                    coninfo.EngineType = EngineType.UDB;
                    if (File.Exists("./" + workspaceName + ".udb"))
                    {

                        if (datasources.Contains(workspaceName))
                        {
                            Datasource datasource = datasources[workspaceName];
                            datasets = datasource.Datasets;
                        }
                        else
                        {
                            Datasource datasource = datasources.Open(coninfo);
                            datasets = datasource.Datasets;
                        }
                    }
                    else
                    {
                        Console.WriteLine(".......影像栅格图层没有关联数据，请指定，如果继续，将不会转换影像栅格图层........");
                        Log(String.Format("Error:图层 {0} 没有预先转换grid数据,对应分组 ： {1}\r\n.......影像栅格图层没有关联数据，请指定，如果没有，将不会转换影像栅格图层........\r\n",pLayer.Name,iGrouplayer.Name));
                        continue;
                    }

                    Console.WriteLine("该图层为 RasterLayer 对应supermap 栅格图层 和 影像图层");
                    Log(String.Format("Info:该图层{0}为 RasterLayer 对应supermap 栅格图层 和 影像图层",pLayer.Name));
                    IRasterLayer pRasterLayer = (IRasterLayer)pLayer;
                    IRasterRenderer rasterRender = pRasterLayer.Renderer;

                    Dataset dataset = datasets[pDN.Name];
                    if (dataset == null || dataset is DatasetImage)
                    {
                        if (dataset is DatasetImage)
                        {
                            superMapLayerGroup.Layers.Add(dataset, true);
                            Log(String.Format("Info:预转换的UDB中：图层： {0} 数据集： {1},为image，直接添加到地图", pLayer.Name, pDN.Name));
                            continue;
                        }

                        Log(String.Format("Error:预转换的UDB中不存在rasterlayer： {0} 需要的 GRID数据集： {1},请检查转换的supermap数据集", pLayer.Name, pDN.Name));
                        continue;
                    }
                    DatasetGrid grid = (DatasetGrid)dataset;

                    if (rasterRender is RasterUniqueValueRenderer)
                    {                   
                        ThemeGridUnique gridUnique = new ThemeGridUnique();
                        IRasterUniqueValueRenderer unique = rasterRender as IRasterUniqueValueRenderer;
                        
                        if (unique.HeadingCount == 1)
                        {
                            for (int m = 0; m < unique.ClassCount[0]; m++)
                            {
                                ThemeGridUniqueItem item = new ThemeGridUniqueItem();
                                string label = unique.Label[0, m];
                                ISymbol uniqueSymbol = unique.Symbol[0, m];
                                object value = unique.Value[0, m, 0];
                                if (value is double || value is Int32)
                                {
                                    item.Unique = Convert.ToDouble(value);
                                }
                                if (uniqueSymbol is IFillSymbol)
                                {
                                    IFillSymbol fillsymbol = uniqueSymbol as IFillSymbol;
                                    
                                    item.Color = ConvertToSystemColor(fillsymbol.Color);
                                }

                                item.Caption = label;
                                gridUnique.Add(item);
                                item.IsVisible = true;

                            }

                            string defaultLabel = unique.DefaultLabel;

                            try
                            {
                                if (unique.DefaultSymbol != null)
                                {
                                    ISymbol defaultSymbol = unique.DefaultSymbol;
                                    if (defaultSymbol is IFillSymbol)
                                    {
                                        IFillSymbol fillsymbol = defaultSymbol as IFillSymbol;

                                        gridUnique.DefaultColor = ConvertToSystemColor(fillsymbol.Color);
                                    }
                                }
                            }
                            catch (System.Exception )
                            {
                                gridUnique.DefaultColor = Color.FromArgb(1, 0, 0, 0);
                            }
                        }
                        else
                        {
                            Console.WriteLine("HeadingCount 大于1  ,不支持这样的专题图类型");
                            Log(String.Format("Error:HeadingCount 大于1  ,不支持这样的专题图类型,图层名为 {0} , 对应分组为 {1}",pLayer.Name,iGrouplayer.Name));
                            continue;
                        }
                        Log("attetion! supermap单值栅格专题图的默认值不能设置可见性！！");
                        themeList.Add(gridUnique);
                        superMapLayerGroup.Layers.Add(grid, gridUnique,false);
                        Layer gridlayer = superMapLayerGroup.Layers[superMapLayerGroup.Layers.Count -1];
                        gridlayer.Caption = pLayer.Name;
                    }
                    else if (rasterRender is RasterClassifyColorRampRenderer)
                    {    
                        IRasterClassifyColorRampRenderer classifyBreakRender = rasterRender as IRasterClassifyColorRampRenderer;
                        int classCount = classifyBreakRender.ClassCount;
                        double minValue = Double.MinValue;
                        ThemeGridRange supermapThemeGridRange = new ThemeGridRange();

                        for (int k = 0; k < classCount; k++)
                        {
                            SuperMap.Mapping.ThemeGridRangeItem supermapThemeGridRangeitem = new SuperMap.Mapping.ThemeGridRangeItem();
                            supermapThemeGridRangeitem.Caption = classifyBreakRender.Label[k];
                            supermapThemeGridRangeitem.Start = minValue;
                            supermapThemeGridRangeitem.End = classifyBreakRender.get_Break(k) + 0.0000001;
                            minValue = supermapThemeGridRangeitem.End;

                            ISymbol pSymbol = classifyBreakRender.Symbol[k];

                            if (pSymbol is IFillSymbol)
                            {
                                IFillSymbol fillsymbol = pSymbol as IFillSymbol;
                                if (fillsymbol is SimpleFillSymbol)
                                {
                                    SimpleFillSymbol simple = fillsymbol as SimpleFillSymbol;
                                    supermapThemeGridRangeitem.Color = ConvertToSystemColor(simple.Color);
                                    supermapThemeGridRange.AddToTail(supermapThemeGridRangeitem);
                                }
                                else
                                {
                                    supermapThemeGridRangeitem.Color = ConvertToSystemColor(fillsymbol.Color);
                                    supermapThemeGridRange.AddToTail(supermapThemeGridRangeitem);
                                }
                            }
                            else
                            {
                                Console.WriteLine("改分段专题图为点符号分段，supermap中不支持该分段专题图");
                                Log(String.Format("Error:改分段专题图为点符号分段，supermap中不支持改分段专题图,,图层名为 {0} , 对应分组为 {1}",pLayer.Name,iGrouplayer.Name));
                                //分段栅格专题图 
                                Console.WriteLine("图层 {0} 中的栅格专题类型 RasterClassifyColorRampRenderer是supermap暂时不支持的", pLayer.Name);
                                continue;
                            }
                        }
                        Log("attetion! supermap中栅格的无值显示有问题！");
                        themeList.Add(supermapThemeGridRange);
                        superMapLayerGroup.Layers.Add(grid, supermapThemeGridRange,false);
                        Layer gridlayer = superMapLayerGroup.Layers[superMapLayerGroup.Layers.Count - 1];
                        gridlayer.Caption = pLayer.Name;
                        
                        //分段栅格专题图 
                    }
                    else if (rasterRender is RasterStretchColorRampRenderer)
                    {//普通图层

                        //supermap中只支持grid的专题图类型，所以影像都导入为栅格
                        //render values along color ramp
                        //int index = pRStretchRender.BandIndex;

                        IRasterStretchColorRampRenderer pRStretchRender = rasterRender as IRasterStretchColorRampRenderer;
                        //int classCount = pRStretchRender.ClassCount;

                        string colorscheme = pRStretchRender.ColorScheme;
                        IColorRamp colorRamp = pRStretchRender.ColorRamp;
                        LayerSettingGrid settingGrid = new LayerSettingGrid();
                        translateColorRamp(colorRamp, settingGrid, pLayer);

                        superMapLayerGroup.Layers.Add(grid, settingGrid, false);
                        Layer gridlayer = superMapLayerGroup.Layers[superMapLayerGroup.Layers.Count - 1];
                        gridlayer.Caption = pLayer.Name;
                    }
                    else if (rasterRender is RasterColormapRenderer)
                    {
                        // The RasterColormapRenderer object displays raster data that has an existing colormap.
                        Console.WriteLine("图层 {0} 中的栅格专题类型RasterColormapRenderer 是supermap暂时不支持的", pLayer.Name);
                        Log(String.Format("Error:图层 {0} 中的栅格专题类型RasterColormapRenderer 是supermap暂时不支持的", pLayer.Name));

                    }
                    else if (rasterRender is RasterDiscreteColorRenderer)
                    {
                        Console.WriteLine("图层 {0} 中的栅格专题类型RasterDiscreteColorRenderer 是supermap暂时不支持的", pLayer.Name);
                        Log(String.Format("Error:图层 {0} 中的栅格专题类型RasterDiscreteColorRenderer 是supermap暂时不支持的,对应图层分组为 {1}", pLayer.Name,iGrouplayer.Name));
                    }
                    else if (rasterRender is RasterRGBRenderer)
                    {
                        Console.WriteLine("图层 {0} 中的栅格专题类型RasterRGBRenderer 是supermap暂时不支持的", pLayer.Name);
                        Log(String.Format("Error:图层 {0} 中的栅格专题类型RasterRGBRenderer 是supermap暂时不支持的,,对应图层分组为 {1}", pLayer.Name,iGrouplayer.Name));
                    }

                    Log(String.Format("Info:将图层:<{0}> 转换为 supermap 图层，完毕", pLayer.Name));
                }
                else
                {
                    Console.WriteLine("该图层{0} 的类型，supermap中暂时不支持，请手动完成转换", pLayer.Name);
                    Log(String.Format("Error:该图层：<{0}> 的类型，supermap中暂时不支持，请手动完成转换", pLayer.Name));
                }
            }
        }

        /// <summary>
        /// 输出符号库
        /// </summary>
        /// <param name="styleFolder"></param>
        /// <returns></returns>
        public static void Output(String styleFolder)
        {
            String[] styleFiles = Directory.GetFiles(styleFolder, "*.style", SearchOption.AllDirectories);
            // 点符号
            foreach (String file in styleFiles)
            {
                Console.WriteLine("start output styleFile: {0}", file.Substring(styleFolder.Length + 1));
                OutputStyle(file, GDB_TABLE_MARKER);
                Console.WriteLine("finish output styleFile: {0}", file.Substring(styleFolder.Length + 1));
            }
            // 线型，但无法转成SuperMap格式
            foreach (String file in styleFiles)
            {
                Console.WriteLine("start output styleFile: {0}", file.Substring(styleFolder.Length + 1));
                OutputStyle(file, GDB_TABLE_LINE);
                Console.WriteLine("finish output styleFile: {0}", file.Substring(styleFolder.Length + 1));
            }

            // 填充
            foreach (String file in styleFiles)
            {
                Console.WriteLine("start output styleFile: {0}", file.Substring(styleFolder.Length + 1));
                OutputStyle(file, GDB_TABLE_AREA);
                Console.WriteLine("finish output styleFile: {0}", file.Substring(styleFolder.Length + 1));
            }

            Console.WriteLine("All done");
        }

        /// <summary>
        /// 输出符号库
        /// </summary>
        /// <param name="file"></param>
        /// <param name="symbolTableName"></param>
        /// <returns></returns>
        private static void OutputStyle(string file, String symbolTableName)
        {
            // Get Drawing Context
            Int32 width = 32;

            Bitmap graphicBitmap = new Bitmap(width, width);
            Graphics graphics = Graphics.FromImage(graphicBitmap);

            Resources supermapResource = new Resources();
            IStyleGalleryStorage styleGalleryStorage = (IStyleGalleryStorage)WindowsAPI.StyleGallery;
            styleGalleryStorage.TargetFile = file;

            IEnumStyleGalleryItem styleGalleryItems = WindowsAPI.StyleGallery.get_Items(symbolTableName, file, "");
            styleGalleryItems.Reset();

            IStyleGalleryItem symbolGallery = null;

            do
            {
                symbolGallery = styleGalleryItems.Next();
                if (symbolGallery == null || symbolGallery.Item == null)
                {
                    continue;
                }


                ISymbol item = symbolGallery.Item as ISymbol;


                if (item is ISymbol3D)
                {
                    Console.WriteLine("{0} is Symbol3D", symbolGallery.Name);
                    continue;
                }

                // 如果是点符号需要进行调整大小，填充、线型采用32个像素
                if (item is IMarkerSymbol)
                {
                    IMarkerSymbol markerSymbol = symbolGallery.Item as IMarkerSymbol;

                    IMultiLayerMarkerSymbol multiLayerSymbol = markerSymbol as IMultiLayerMarkerSymbol;

                    width = (Int32)markerSymbol.Size + 12;
                    if (multiLayerSymbol != null && multiLayerSymbol.LayerCount > 0)
                    {
                        IMarkerSymbol layerSymbol = multiLayerSymbol.Layer[0];
                        Double offset = Math.Abs(layerSymbol.YOffset) + Math.Abs(layerSymbol.XOffset);
                        // 如果是栅格填充再增加16个像素
                        if (offset > 0.005)
                        {
                            width += (Int32)Math.Round(offset) + 16;
                        }
                    }
                    // Convert ESRI Symbol to Bitmap
                    //该实现方法使用arcgis原有的点符号尺寸，输出图片，然后直接输入到supermap符号库
                    Size size = new Size(width, width);

                    Bitmap bitmap = WindowsAPI.SymbolToBitmap(markerSymbol as ISymbol, size, graphics, ColorTranslator.ToWin32(BACKCOLOR));

                    bitmap.MakeTransparent(BACKCOLOR);


                    Rectangle2D rect = new Rectangle2D(0, 0, width, width);
                    GeoPicture picture = new GeoPicture(bitmap, rect, 0);
                    SymbolMarker marker = new SymbolMarker();
                    marker.FromGeometry(picture, rect);

                    supermapResource.MarkerLibrary.Add(marker);

                    bitmap.Dispose();
                }

                // Convert ESRI Symbol to Bitmap

                if (item is IMultiLayerFillSymbol)
                {
                    Size size = new Size(width, width);
                    IFillSymbol layer0Symbol = (item as IMultiLayerFillSymbol).Layer[0];
                    // 去掉边线
                    layer0Symbol.Outline = null;

                    if (layer0Symbol is IPictureFillSymbol)
                    {
                        IPictureFillSymbol pictureSymbol = layer0Symbol as IPictureFillSymbol;
                        stdole.IPictureDisp picture = pictureSymbol.Picture;
                        try
                        {
                            Bitmap image = System.Drawing.Bitmap.FromHbitmap(new System.IntPtr(picture.Handle));
                            size = new Size(image.Width, image.Height);
                            image.Dispose();
                        }
                        catch (ExternalException)
                        {
                            size = new Size(32, 32);
                        }

                    }
                    else if (layer0Symbol is ILineFillSymbol)
                    {
                        size = new Size(10, 10);
                    }
                }

            } while (symbolGallery != null);

            if (symbolTableName == GDB_TABLE_MARKER)
            {
                Console.WriteLine("开始保存符号库库文件");
                string filePath = System.IO.Path.GetFileNameWithoutExtension(file);
                if (System.IO.File.Exists(filePath))
                {
                    Console.WriteLine("符号库库文件同名");
                    return;
                }

                if (supermapResource.MarkerLibrary.ToFile(filePath))
                {
                    Console.WriteLine("符号库导出成功，路径为 " + filePath);
                }
            }

            graphics.Dispose();
            graphicBitmap.Dispose();
            WindowsAPI.UnLoadStyleFile();
        }

        private static Color ConvertToSystemColor(IColor esriColor)
        {
            Color systemColor = new Color();
            if (esriColor is RgbColor)
            {
                IRgbColor color = esriColor as RgbColor;
                systemColor = Color.FromArgb(color.Transparency, color.Red, color.Green, color.Blue);
            }
            else if (esriColor is CmykColor)
            {
                ICmykColor color = esriColor as CmykColor;
                systemColor = Color.FromArgb(color.Transparency, color.RGB & 0Xff, color.RGB >> 8 & 0Xff, color.RGB >> 16 & 0Xff);
            }
            else if (esriColor is GrayColor)
            {
                IGrayColor color = esriColor as GrayColor;
                systemColor = Color.FromArgb(color.Transparency, color.RGB & 0Xff, color.RGB >> 8 & 0Xff, color.RGB >> 16 & 0Xff);
            }
            else if (esriColor is HlsColor)
            {
                IHlsColor color = esriColor as HlsColor;
                systemColor = Color.FromArgb(color.Transparency, color.RGB & 0Xff, color.RGB >> 8 & 0Xff, color.RGB >> 16 & 0Xff);
            }
            else if (esriColor is HsvColor)
            {
                IHsvColor color = esriColor as HsvColor;

                systemColor = Color.FromArgb(color.Transparency, color.RGB & 0Xff, color.RGB >> 8 & 0Xff, color.RGB >> 16 & 0Xff);
            }
            else
            {
                systemColor = Color.FromArgb(esriColor.RGB);
            }

            return systemColor;
        }

        private static void SymbolizeToSuperMapSymbolLib(GeoStyle supermapGeoStyle, Resources supermapResource, ISymbol pSymbol, string name)
        {
            //符号化部分没有完成
            if (pSymbol is IMarkerSymbol)
            {
                IMarkerSymbol pMakerSymbol = pSymbol as IMarkerSymbol;
                double makerAngle = pMakerSymbol.Angle;
                IColor icolor = pMakerSymbol.Color;
                double makerSize = pMakerSymbol.Size;
                double offsetX = pMakerSymbol.XOffset;
                double offsetY = pMakerSymbol.YOffset;

                supermapGeoStyle.MarkerAngle = makerAngle;
                supermapGeoStyle.MarkerSize = new Size2D(makerSize, makerSize);


                IMultiLayerMarkerSymbol multiLayerSymbol = pMakerSymbol as IMultiLayerMarkerSymbol;

                Int32 width = (Int32)pMakerSymbol.Size + 8;
                if (multiLayerSymbol != null && multiLayerSymbol.LayerCount > 0)
                {
                    IMarkerSymbol layerSymbol = multiLayerSymbol.Layer[0];
                    Double offset = Math.Abs(layerSymbol.YOffset) + Math.Abs(layerSymbol.XOffset);
                    // 如果是栅格填充再增加16个像素
                    if (offset > 0.005)
                    {
                        width += (Int32)Math.Round(offset) + 16;
                    }
                }
                // Convert ESRI Symbol to Bitmap
                //该实现方法使用arcgis原有的点符号尺寸，输出图片，然后直接输入到supermap符号库
                Size size = new Size(width, width);
                Bitmap graphicBitmap = new Bitmap(width, width);
                Graphics graphics = Graphics.FromImage(graphicBitmap);
                Bitmap bitmap = WindowsAPI.SymbolToBitmap(pMakerSymbol as ISymbol, size, graphics, ColorTranslator.ToWin32(BACKCOLOR));

                bitmap.MakeTransparent(BACKCOLOR);


                Rectangle2D rect = new Rectangle2D(0, 0, width, width);
                GeoPicture picture = new GeoPicture(bitmap, rect, 0);
                SymbolMarker marker = new SymbolMarker();
                marker.FromGeometry(picture, rect);
                marker.Name = name;

                marker.Name = name + "_esri";

                //避免重名，导致查找名称异常
                Symbol symbol = supermapResource.MarkerLibrary.FindSymbol(marker.Name);
                Int32 i = 0;
                while (true)
                {
                    if (symbol == null)
                    {
                        if (i > 0)
                        {
                            marker.Name = marker.Name + "_" + i.ToString();
                        }

                        supermapResource.MarkerLibrary.Add(marker);

                        symbol = supermapResource.MarkerLibrary.FindSymbol(marker.Name);

                        break;
                    }
                    else
                    {
                        i++;
                        symbol = supermapResource.MarkerLibrary.FindSymbol(marker.Name + "_" + i.ToString());
                    }
                }
                supermapGeoStyle.MarkerSymbolID = symbol.ID;

                //Size2D size2d = new Size2D(SumakerSize/4, SumakerSize/4);
                Size2D size2d = new Size2D(0, 0);
                supermapGeoStyle.MarkerSize = size2d;
            }
            else if (pSymbol is ILineSymbol)
            {
                //线符号，比较复杂，稍后继续……^>^

                //                 线符号类型	描述
                //                  CartographicLineSymbol	实心或者虚线线符号
                //                  HashLineSymbol	离散线符号
                //                  MarkerLineSymbol	点线符号
                //                  MultiLayerLineSymbol	多符号叠加产生新线符号
                //                  PictureLineSymbol	图片线符号
                //                  SimpleLine3DSymbol	3D 线符号
                //                  SimpleLineSymbol	预定义风格的线符号
                //                  TextureLineSymbol (3DAnalyst)	纹理贴 图线符号


                ILineSymbol lineSymbol = pSymbol as ILineSymbol;

                if (lineSymbol is IMultiLayerLineSymbol)
                {
                    IMultiLayerLineSymbol LineSymbols = lineSymbol as IMultiLayerLineSymbol;
                    SymbolLine symbolLine = new SymbolLine();

                    int count = LineSymbols.LayerCount;


                    SymbolLine supermapSymbolLine = new SymbolLine();
                    for (int n = LineSymbols.LayerCount - 1; n >= 0; n--)
                    {
                        ILineSymbol alinesymbol = LineSymbols.Layer[n];
                        SymbolLineBase supermapLineBase = new SymbolLineBase();
                        if (alinesymbol is ICartographicLineSymbol)
                        {
                            ICartographicLineSymbol cartographicLineSymbol = alinesymbol as ICartographicLineSymbol;

                            ESRI.ArcGIS.Display.ILineProperties lineProperties = cartographicLineSymbol as ESRI.ArcGIS.Display.ILineProperties;
                            //lineProperties.Offset = 0;

                            ESRI.ArcGIS.Display.ITemplate template = template = lineProperties.Template;

                            int patternElementCount = 0;
                            Double Interval = 0;
                            try
                            {
                                patternElementCount = template.PatternElementCount;
                                Interval = template.Interval;
                            }
                            catch (System.Exception)
                            {
                                patternElementCount = 0;
                            }
                            

                            Int32[] solidPattern = new Int32[patternElementCount * 2];
                            
                            for (int k = 0, j = 0; k < patternElementCount; k++, j += 2)
                            {
                                double mark;
                                double gap;
                                template.GetPatternElement(k, out mark, out gap);
                                solidPattern[j] = Convert.ToInt32(mark * 25.4 / 72 * 10 * Interval);
                                solidPattern[j + 1] = Convert.ToInt32(gap * 25.4 / 72 * 10 * Interval);
                            }
                            supermapLineBase.SolidPattern = solidPattern;

                            //设置线性基本风格

                            ESRI.ArcGIS.Display.esriLineCapStyle capStyle = cartographicLineSymbol.Cap;

                            switch (capStyle)
                            {
                                case esriLineCapStyle.esriLCSSquare:
                                    supermapLineBase.CapType = LineCapType.Square;
                                    break;
                                case esriLineCapStyle.esriLCSRound:
                                    supermapLineBase.CapType = LineCapType.Round;
                                    break;
                                case esriLineCapStyle.esriLCSButt:
                                    supermapLineBase.CapType = LineCapType.Flat;
                                    break;
                            }

                            ESRI.ArcGIS.Display.esriLineJoinStyle joinStyle = cartographicLineSymbol.Join;

                            switch (joinStyle)
                            {
                                case esriLineJoinStyle.esriLJSBevel:
                                    supermapLineBase.JoinType = LineJoinType.Bevel;
                                    break;
                                case esriLineJoinStyle.esriLJSMitre:
                                    supermapLineBase.JoinType = LineJoinType.Miter;
                                    break;
                                case esriLineJoinStyle.esriLJSRound:
                                    supermapLineBase.JoinType = LineJoinType.Round;
                                    break;
                            }

                            IColor linecolor = cartographicLineSymbol.Color;
                            supermapLineBase.FixedColor = ConvertToSystemColor(linecolor);

                            if (supermapLineBase.FixedColor.A == 0)
                            {
                                Color lineColor = supermapLineBase.FixedColor;
                                supermapLineBase.FixedColor = Color.FromArgb(1, lineColor.R, lineColor.G, lineColor.B);
                            }

                            supermapLineBase.IsColorFixed = true;

                            Double width = cartographicLineSymbol.Width;
                            supermapLineBase.FixedWidth = Convert.ToInt32(width * 25.4 / 72 * 10);
                            supermapLineBase.IsWidthFixed = true;

                            supermapSymbolLine.Add(supermapLineBase);
                        }
                        else if (alinesymbol is IHashLineSymbol)
                        {
                            Log("Error:复杂线性不支持转换");
                            //                             supermapLineBase.Type = SymbolLineBaseType.AlignmentCenter;
                            //                             IHashLineSymbol hashLineSymbol = alinesymbol as IHashLineSymbol;
                            // 
                            //                             ESRI.ArcGIS.Display.ILineProperties lineProperties = hashLineSymbol as ESRI.ArcGIS.Display.ILineProperties;
                            //                             //lineProperties.Offset = 0;
                            // 
                            //                             ESRI.ArcGIS.Display.ITemplate template = template = lineProperties.Template;
                            // 
                            //                             int patternElementCount = template.PatternElementCount;
                            // 
                            //                             Int32[] solidPattern = new Int32[patternElementCount * 2];
                            //                             Double Interval = template.Interval;
                            //                             for (int k = 0, j = 0; k < patternElementCount; k++, j += 2)
                            //                             {
                            //                                 double mark;
                            //                                 double gap;
                            //                                 template.GetPatternElement(k, out mark, out gap);
                            //                                 solidPattern[j] = Convert.ToInt32(mark * 25.4 / 72 * 10 * Interval);
                            //                                 solidPattern[j + 1] = Convert.ToInt32(gap * 25.4 / 72 * 10 * Interval);
                            //                             }
                            //                             supermapLineBase.SolidPattern = solidPattern;
                            // 
                            //                             //设置线性基本风格
                            // 
                            //                             ESRI.ArcGIS.Display.esriLineCapStyle capStyle = hashLineSymbol.HashSymbol;
                            // 
                            //                             switch (capStyle)
                            //                             {
                            //                                 case esriLineCapStyle.esriLCSSquare:
                            //                                     supermapLineBase.CapType = LineCapType.Square;
                            //                                     break;
                            //                                 case esriLineCapStyle.esriLCSRound:
                            //                                     supermapLineBase.CapType = LineCapType.Round;
                            //                                     break;
                            //                                 case esriLineCapStyle.esriLCSButt:
                            //                                     supermapLineBase.CapType = LineCapType.Flat;
                            //                                     break;
                            //                             }
                            // 
                            //                             ESRI.ArcGIS.Display.esriLineJoinStyle joinStyle = cartographicLineSymbol.Join;
                            // 
                            //                             switch (joinStyle)
                            //                             {
                            //                                 case esriLineJoinStyle.esriLJSBevel:
                            //                                     supermapLineBase.JoinType = LineJoinType.Bevel;
                            //                                     break;
                            //                                 case esriLineJoinStyle.esriLJSMitre:
                            //                                     supermapLineBase.JoinType = LineJoinType.Miter;
                            //                                     break;
                            //                                 case esriLineJoinStyle.esriLJSRound:
                            //                                     supermapLineBase.JoinType = LineJoinType.Round;
                            //                                     break;
                            //                             }
                            // 
                            //                             IColor linecolor = cartographicLineSymbol.Color;
                            //                             supermapLineBase.FixedColor = ConvertToSystemColor(linecolor);
                            //                             supermapLineBase.IsColorFixed = true;
                            // 
                            //                             Double width = cartographicLineSymbol.Width;
                            //                             supermapLineBase.FixedWidth = Convert.ToInt32(width * 25.4 / 72 * 10);
                            //                             supermapLineBase.IsWidthFixed = true;
                            // 
                            //                             supermapSymbolLine.Add(supermapLineBase);
                        }
                        else if (alinesymbol is SimpleLineSymbol)
                        {
                            ISimpleLineSymbol simplelineSymbol = alinesymbol as ISimpleLineSymbol;
                            if (simplelineSymbol.Width == 0)
                            {
                                supermapLineBase.FixedColor = ConvertToSystemColor(simplelineSymbol.Color);
                                simplelineSymbol.Style = esriSimpleLineStyle.esriSLSNull;
                                if (supermapLineBase.FixedColor.A == 0)
                                {
                                    Color lineColor = supermapLineBase.FixedColor;
                                    supermapLineBase.FixedColor = Color.FromArgb(1, lineColor.R, lineColor.G, lineColor.B);
                                }
                            }
                            else
                            {
                                if (simplelineSymbol.Width < 0)
                                {
                                    supermapLineBase.FixedWidth = 0;//该处取得的是Points ，转换为毫米
                                }
                                else
                                {
                                    supermapLineBase.FixedWidth = (int)(simplelineSymbol.Width * 25.4 / 72*10);//该处取得的是Points ，转换为毫米
                                }
                                
                                supermapLineBase.FixedColor = ConvertToSystemColor(simplelineSymbol.Color);
                                if (supermapLineBase.FixedColor.A == 0)
                                {
                                    Color lineColor = supermapLineBase.FixedColor;
                                    supermapLineBase.FixedColor = Color.FromArgb(1, lineColor.R, lineColor.G, lineColor.B);
                                }
                            }
                            esriSimpleLineStyle style = simplelineSymbol.Style;

                            switch (style)
                            {
                                case esriSimpleLineStyle.esriSLSSolid:
                                    supermapGeoStyle.LineSymbolID = 0;
                                    break;
                                case esriSimpleLineStyle.esriSLSNull:
                                    supermapGeoStyle.LineSymbolID = 5;
                                    break;
                                case esriSimpleLineStyle.esriSLSDot:
                                    supermapGeoStyle.LineSymbolID = 2;
                                    break;
                                case esriSimpleLineStyle.esriSLSDashDotDot:
                                    supermapGeoStyle.LineSymbolID = 4;
                                    break;
                                case esriSimpleLineStyle.esriSLSDashDot:
                                    supermapGeoStyle.LineSymbolID = 3;
                                    break;
                                case esriSimpleLineStyle.esriSLSDash:
                                    supermapGeoStyle.LineSymbolID = 1;
                                    break;
                                case esriSimpleLineStyle.esriSLSInsideFrame:
                                    supermapGeoStyle.LineSymbolID = 0;
                                    break;
                            }
                        }
                        else if (alinesymbol is IMarkerLineSymbol)
                        {
                            Log("Error:IMarkerLineSymbol 复杂线性不支持转换\r\n");
                        }
                        supermapLineBase.IsColorFixed = true;
                        supermapLineBase.IsWidthFixed = true;
                        supermapSymbolLine.Add(supermapLineBase);
                    }
                    supermapSymbolLine.Name = name + "_esri";

                    //避免重名，导致查找名称异常
                    Symbol symbol = supermapResource.LineLibrary.FindSymbol(supermapSymbolLine.Name);
                    Int32 i = 0;
                    while (true)
                    {
                        if (symbol == null)
                        {
                            if (i > 0)
                            {
                                supermapSymbolLine.Name = supermapSymbolLine.Name + "_" + i.ToString();
                            }

                            supermapResource.LineLibrary.Add(supermapSymbolLine);

                            symbol = supermapResource.LineLibrary.FindSymbol(supermapSymbolLine.Name);

                            break;
                        }
                        else
                        {
                            i++;
                            symbol = supermapResource.LineLibrary.FindSymbol(supermapSymbolLine.Name + "_" + i.ToString());
                        }
                    }

                    supermapGeoStyle.LineSymbolID = symbol.ID;

                }
                else if (lineSymbol is ISimpleLineSymbol)
                {
                    ISimpleLineSymbol simplelineSymbol = lineSymbol as ISimpleLineSymbol;
                    if (simplelineSymbol.Width == 0)
                    {
                        supermapGeoStyle.LineColor = ConvertToSystemColor(simplelineSymbol.Color);
                        simplelineSymbol.Style = esriSimpleLineStyle.esriSLSNull;
                        if (supermapGeoStyle.LineColor.A == 0)
                        {
                            Color lineColor = supermapGeoStyle.LineColor;
                            supermapGeoStyle.LineColor = Color.FromArgb(1, lineColor.R, lineColor.G, lineColor.B);
                        }
                    }
                    else
                    {
                        supermapGeoStyle.LineWidth = simplelineSymbol.Width * 25.4 / 72;//该处取得的是Points ，转换为毫米
                        supermapGeoStyle.LineColor = ConvertToSystemColor(simplelineSymbol.Color);
                        if (supermapGeoStyle.LineColor.A == 0)
                        {
                            Color lineColor = supermapGeoStyle.LineColor;
                            supermapGeoStyle.LineColor = Color.FromArgb(1, lineColor.R, lineColor.G, lineColor.B);
                        }
                    }
                    esriSimpleLineStyle style = simplelineSymbol.Style;

                    switch (style)
                    {
                        case esriSimpleLineStyle.esriSLSSolid:
                            supermapGeoStyle.LineSymbolID = 0;
                            break;
                        case esriSimpleLineStyle.esriSLSNull:
                            supermapGeoStyle.LineSymbolID = 5;
                            break;
                        case esriSimpleLineStyle.esriSLSDot:
                            supermapGeoStyle.LineSymbolID = 2;
                            break;
                        case esriSimpleLineStyle.esriSLSDashDotDot:
                            supermapGeoStyle.LineSymbolID = 4;
                            break;
                        case esriSimpleLineStyle.esriSLSDashDot:
                            supermapGeoStyle.LineSymbolID = 3;
                            break;
                        case esriSimpleLineStyle.esriSLSDash:
                            supermapGeoStyle.LineSymbolID = 1;
                            break;
                        case esriSimpleLineStyle.esriSLSInsideFrame:
                            supermapGeoStyle.LineSymbolID = 0;
                            break;
                    }

                }
                else if (lineSymbol is CartographicLineSymbol)
                {

                }
                else if (lineSymbol is HashLineSymbol)
                {
                    Log("Error:HashLineSymbol复杂线性不支持转换");
                }
                else if (lineSymbol is MarkerLineSymbol)
                {
                    Log("Error:MarkerLineSymbol复杂线性不支持转换");
                }
                else if (lineSymbol is PictureLineSymbol)
                {
                    Log("Error:PictureLineSymbol复杂线性不支持转换");
                }
            }
            else if (pSymbol is IFillSymbol)
            {
                //                 填充符号类型	描述
                // ColorRampSymbol (Carto)	用于渲染Raster数据的颜色带
                // ColorSymbol (Carto)	用于渲染Raster数据的颜色符号
                // DotDensityFillSymbol	点密度填充符号
                // GradientFillSymbol	渐变填充符号
                // LineFillSymbol	包含线符号的填充符号
                // MarkerFillSymbol	包含点符号的填充符号
                // MultiLayerFillSymbol	多符号叠加产生新填充符号
                // PictureFillSymbol	图片填充符号
                // RasterRGBSymbol	用于渲染Raster数据　RGBSymbol
                // SimpleFillSymbol	简单填充符号
                // TextureFillSymbol	纹理贴图填充符号
                SymbolFill symbolFill = new SymbolFill();

                if (pSymbol is IMultiLayerFillSymbol)
                {
                    Console.WriteLine("arcmap中填充符号存储了边线，而supermap中没有存储，而是在style中设置，当当前面符号为多层叠加时，无法设置多层的边线，可能会出现错误！");
                    Log("Warning:arcmap中填充符号存储了边线，而supermap中没有存储，而是在style中设置，当当前面符号为多层叠加时，无法设置多层的边线，可能会出现错误！");
                    IMultiLayerFillSymbol mutilayer = pSymbol as IMultiLayerFillSymbol;
                    //IFillSymbol pFillSymbol = (pSymbol as IMultiLayerFillSymbol).Layer[0];

                    for (int i = 0; i < mutilayer.LayerCount; i++)
                    {
                        IFillSymbol pFillSymbol = mutilayer.get_Layer(i);

                        SymbolFillBase fillBase = new SymbolFillBase();
                        if (pFillSymbol is GradientFillSymbol)
                        {
                            IGradientFillSymbol gradientFillSymbol = pFillSymbol as IGradientFillSymbol;

                            IColor esriColor = gradientFillSymbol.Color;
                            double gradientAngle = gradientFillSymbol.GradientAngle;
                            ILineSymbol esrigradientLineSymbol = gradientFillSymbol.Outline;
                            esriGradientFillStyle gradientFillSymbolStyle = gradientFillSymbol.Style;
                            SymbolizeToSuperMapSymbolLib(supermapGeoStyle, supermapResource, esrigradientLineSymbol as ISymbol, name);

                            switch (gradientFillSymbolStyle)
                            {
                                case esriGradientFillStyle.esriGFSRectangular:
                                    supermapGeoStyle.FillGradientMode = FillGradientMode.Square;
                                    break;
                                case esriGradientFillStyle.esriGFSLinear:
                                    supermapGeoStyle.FillGradientMode = FillGradientMode.Linear;
                                    break;
                                case esriGradientFillStyle.esriGFSCircular:
                                    supermapGeoStyle.FillGradientMode = FillGradientMode.Radial;
                                    break;
                                case esriGradientFillStyle.esriGFSBuffered:
                                    supermapGeoStyle.FillGradientMode = FillGradientMode.Radial;
                                    break;
                                default:
                                    supermapGeoStyle.FillGradientMode = FillGradientMode.None;
                                    break;
                            }
                            IColorRamp colorRamp = gradientFillSymbol.ColorRamp;
                            if (colorRamp is IAlgorithmicColorRamp)
                            {
                                IAlgorithmicColorRamp differentColors = gradientFillSymbol.ColorRamp as IAlgorithmicColorRamp;
                                IColor toColor = differentColors.ToColor;
                                IColor fromColor = differentColors.FromColor;
                                Color[] colors = new Color[2];
                                colors[0] = ConvertToSystemColor(toColor);
                                colors[1] = ConvertToSystemColor(fromColor);
                                supermapGeoStyle.FillForeColor = colors[0];
                                supermapGeoStyle.FillBackColor = colors[1];
                                supermapGeoStyle.FillBackOpaque = false;
                                supermapGeoStyle.FillGradientAngle = gradientAngle;
                            }
                            else
                            {

                            }
                            Console.WriteLine("supermap对渐变填充支持的不够完善！");
                            if (mutilayer.LayerCount > 1)
                            {
                                Console.WriteLine("渐变填充不支持多图层组合填充");
                                break;
                            }

                        }
                        else if (pFillSymbol is LineFillSymbol)
                        {
                            ILineFillSymbol lineFillsymbol = pFillSymbol as ILineFillSymbol;
                            Console.WriteLine("supermap不支持ILineFillSymbol的绘制");
                        }
                        else if (pFillSymbol is MarkerFillSymbol)
                        {
                            IMarkerFillSymbol markerFillSymbol = pFillSymbol as IMarkerFillSymbol;

                            IColor esriColor = markerFillSymbol.Color;

                            ILineSymbol esriLineSymbol = markerFillSymbol.Outline;
                            SymbolizeToSuperMapSymbolLib(supermapGeoStyle, supermapResource, esriLineSymbol as ISymbol, name + "fillMaker");



                            IMarkerSymbol makerSymbol = markerFillSymbol.MarkerSymbol;
                            SymbolizeToSuperMapSymbolLib(supermapGeoStyle, supermapResource, makerSymbol as ISymbol, name + "fillMaker");
                            SymbolFillMarker fillMarker = new SymbolFillMarker();
                            fillMarker.MarkerID = supermapResource.MarkerLibrary.FindSymbol(name + "fillMaker" + "_esri").ID;
                            System.Drawing.Point[] points = new System.Drawing.Point[1];
                            //                             points[0] = 
                            //                             fillMarker.

                            //                             esriMarkerFillStyle makerfillstyle = markerFillSymbol.Style;
                            //                             if (makerfillstyle == esriMarkerFillStyle.esriMFSRandom)
                            //                             {
                            //                                 Console.WriteLine("不支持该类型，随机的点符号填充类型！");
                            //                             }
                            //                             fillBase.
                            //                             symbolFill.Add(fillBase);
                            //                             symbolFill.Name = name;
                            //                             supermapResource.FillLibrary.Add(symbolFill);
                            //                             Symbol symbol = supermapResource.FillLibrary.FindSymbol(symbolFill.Name);
                            // 
                            //                             supermapGeoStyle.MarkerSymbolID = symbol.ID;
                            // 
                            // 
                            // 
                            //                             Symbol symbol = supermapResource.FillLibrary.FindSymbol(symbolFill.Name);
                            //                             Int32 i = 0;
                            //                             while (true)
                            //                             {
                            //                                 if (symbol == null)
                            //                                 {
                            //                                     if (i > 0)
                            //                                     {
                            //                                         supermapSymbolLine.Name = supermapSymbolLine.Name + "_" + i.ToString();
                            //                                     }
                            // 
                            //                                     supermapResource.LineLibrary.Add(supermapSymbolLine);
                            // 
                            //                                     symbol = supermapResource.LineLibrary.FindSymbol(supermapSymbolLine.Name);
                            // 
                            //                                     break;
                            //                                 }
                            //                                 else
                            //                                 {
                            //                                     i++;
                            //                                     symbol = supermapResource.LineLibrary.FindSymbol(supermapSymbolLine.Name + "_" + i.ToString());
                            //                                 }
                            //                             }
                            // 
                            //                             supermapGeoStyle.LineSymbolID = symbol.ID;

                        }
                        else if (pSymbol is SimpleFillSymbol)
                        {
                            SimpleFillSymbol simplefill = pSymbol as SimpleFillSymbol;
                            IColor fillColor = simplefill.Color;
                            supermapGeoStyle.FillForeColor = ConvertToSystemColor(fillColor);
                            ILineSymbol lineSymbol = simplefill.Outline;
                            SymbolizeToSuperMapSymbolLib(supermapGeoStyle, supermapResource, lineSymbol as ISymbol, name);

                            esriSimpleFillStyle syle = simplefill.Style;

                            switch (syle)
                            {
                                // 摘要:
                                //     Solid fill.
                                case esriSimpleFillStyle.esriSFSSolid:
                                    supermapGeoStyle.FillSymbolID = 0;
                                    break;
                                //
                                // 摘要:
                                //     Empty fill.
                                // case    esriSimpleFillStyle.esriSFSNull :
                                //
                                // 摘要:
                                //     Hollow fill (same as esriSFSNull).
                                case esriSimpleFillStyle.esriSFSHollow:
                                    supermapGeoStyle.FillSymbolID = 1;
                                    break;
                                //
                                // 摘要:
                                //     Horizontal hatch fill ------.
                                case esriSimpleFillStyle.esriSFSHorizontal:
                                    supermapGeoStyle.FillSymbolID = 6;
                                    break;
                                //
                                // 摘要:
                                //     Vertical hatch fill ||||||.
                                case esriSimpleFillStyle.esriSFSVertical:
                                    supermapGeoStyle.FillSymbolID = 7;
                                    break;
                                //
                                // 摘要:
                                //     45-degree downward, left-to-right hatch fill \\\.
                                case esriSimpleFillStyle.esriSFSForwardDiagonal:
                                    supermapGeoStyle.FillSymbolID = 5;
                                    break;
                                //
                                // 摘要:
                                //     45-degree upward, left-to-right hatch fill //////.
                                case esriSimpleFillStyle.esriSFSBackwardDiagonal:
                                    supermapGeoStyle.FillSymbolID = 2;
                                    break;
                                //
                                // 摘要:
                                //     Horizontal and vertical crosshatch ++++++.
                                case esriSimpleFillStyle.esriSFSCross:
                                    supermapGeoStyle.FillSymbolID = 3;
                                    break;
                                //
                                // 摘要:
                                //     45-degree crosshatch xxxxxx.
                                case esriSimpleFillStyle.esriSFSDiagonalCross:
                                    supermapGeoStyle.FillSymbolID = 4;
                                    break;
                            }
                            //supermapGeoStyle.LineColor = Color.FromArgb(255, 255, 255, 255);
                        }
                        else if (pFillSymbol is DotDensityFillSymbol)
                        {
                            Size size = new Size(50, 50);
                            Bitmap graphicBitmap = new Bitmap(50, 50);
                            Graphics graphics = Graphics.FromImage(graphicBitmap);
                            size = new Size(32, 32);
                            Bitmap bitmap = WindowsAPI.SymbolToBitmap(pFillSymbol as ISymbol, size, graphics, ColorTranslator.ToWin32(BACKCOLOR));

                            // Convert ESRI Symbol to Bitmap

                            bitmap.MakeTransparent(BACKCOLOR);

                            Rectangle2D rect = new Rectangle2D(0, 0, 50, 50);
                            GeoPicture picture = new GeoPicture(bitmap, rect, 0);
                            SymbolMarker marker = new SymbolMarker();
                            marker.FromGeometry(picture, rect);
                            marker.Name = name;
                            supermapResource.MarkerLibrary.Add(marker);

                            fillBase.SetBitmap(bitmap);
                            symbolFill.Add(fillBase);
                            symbolFill.Name = name;
                            supermapResource.FillLibrary.Add(symbolFill);
                            Symbol symbol = supermapResource.FillLibrary.FindSymbol(symbolFill.Name);

                            Int32 g = 0;
                            while (true)
                            {
                                if (symbol == null)
                                {
                                    if (g > 0)
                                    {
                                        symbolFill.Name = symbolFill.Name + "_" + g.ToString();
                                    }

                                    supermapResource.FillLibrary.Add(symbolFill);

                                    symbol = supermapResource.FillLibrary.FindSymbol(symbolFill.Name);

                                    break;
                                }
                                else
                                {
                                    g++;
                                    symbol = supermapResource.FillLibrary.FindSymbol(symbolFill.Name + "_" + g.ToString());
                                }
                                //supermapGeoStyle.LineColor = Color.FromArgb(255, 255, 255, 255);
                            }
                            SymbolizeToSuperMapSymbolLib(supermapGeoStyle, supermapResource, pFillSymbol.Outline as ISymbol, name);
                            supermapGeoStyle.FillSymbolID = symbol.ID;                    

                        }
                        else if (pFillSymbol is PictureFillSymbol)
                        {
                            IPictureFillSymbol iPictureFillSymbol = pFillSymbol as IPictureFillSymbol;
                            stdole.IPictureDisp pictureDisp = iPictureFillSymbol.Picture;

                            Image image = WindowsAPI.PictureDispToImage(pictureDisp);
                           
                            SymbolFillMarker fillMarker = new SymbolFillMarker();
                            //fillMarker.
                            int width = image.Width;
                            int heigh = image.Height;
                            Size size = new Size(width, heigh);
                            double xscale = iPictureFillSymbol.XScale;
                            double yscale = iPictureFillSymbol.YScale;
                           
                            Bitmap graphicBitmap = new Bitmap(image, (int)(width * xscale), (int)(heigh * yscale));
                           
                            graphicBitmap.MakeTransparent(BACKCOLOR);

                            fillBase.SetBitmap(graphicBitmap);
                            symbolFill.Add(fillBase);
                            symbolFill.Name = name + "esrifill";
                            
                            Symbol symbol = supermapResource.FillLibrary.FindSymbol(symbolFill.Name);

                            Int32 g = 0;
                            while (true)
                            {
                                if (symbol == null)
                                {
                                    if (g > 0)
                                    {
                                        symbolFill.Name = symbolFill.Name + "_" + g.ToString();
                                    }

                                    supermapResource.FillLibrary.Add(symbolFill);

                                    symbol = supermapResource.FillLibrary.FindSymbol(symbolFill.Name);

                                    break;
                                }
                                else
                                {
                                    g++;
                                    symbol = supermapResource.FillLibrary.FindSymbol(symbolFill.Name + "_" + g.ToString());
                                }                              
                            }
                            SymbolizeToSuperMapSymbolLib(supermapGeoStyle, supermapResource, pFillSymbol.Outline as ISymbol, name);
                            supermapGeoStyle.FillSymbolID = symbol.ID;  
                            
                        }
                        else
                        {
                            try
                            {
                                IColor color = pFillSymbol.Color;
                                supermapGeoStyle.FillForeColor = ConvertToSystemColor(color);
                                if (supermapGeoStyle.FillForeColor.A == 0)
                                {
                                    Color fillForeColor = supermapGeoStyle.FillForeColor;
                                    supermapGeoStyle.FillForeColor = Color.FromArgb(1, fillForeColor.R, fillForeColor.G, fillForeColor.B);
                                }
                            }
                            catch (System.Exception )
                            {
                                supermapGeoStyle.FillForeColor = Color.FromArgb(1, 255, 255, 255);
                            }
                            SymbolizeToSuperMapSymbolLib(supermapGeoStyle, supermapResource, pFillSymbol.Outline as ISymbol, name);                          
                        }
                    }
                }
                else if (pSymbol is SimpleFillSymbol)
                {
                    SimpleFillSymbol simplefill = pSymbol as SimpleFillSymbol;
                    IColor fillColor = simplefill.Color;
                    supermapGeoStyle.FillForeColor = ConvertToSystemColor(fillColor);

                    if (supermapGeoStyle.FillForeColor.A == 0)
                    {
                        Color foreColor = supermapGeoStyle.FillForeColor;
                        supermapGeoStyle.FillForeColor = Color.FromArgb(1, foreColor.R, foreColor.G, foreColor.B);
                    }
                    
                    ILineSymbol lineSymbol = simplefill.Outline;
                    SymbolizeToSuperMapSymbolLib(supermapGeoStyle, supermapResource, lineSymbol as ISymbol, name);

                    esriSimpleFillStyle syle = simplefill.Style;

                    switch (syle)
                    {
                        // 摘要:
                        //     Solid fill.
                        case esriSimpleFillStyle.esriSFSSolid:
                            supermapGeoStyle.FillSymbolID = 0;
                            break;
                        //
                        // 摘要:
                        //     Empty fill.
                        // case    esriSimpleFillStyle.esriSFSNull :
                        //
                        // 摘要:
                        //     Hollow fill (same as esriSFSNull).
                        case esriSimpleFillStyle.esriSFSHollow:
                            supermapGeoStyle.FillSymbolID = 1;
                            break;
                        //
                        // 摘要:
                        //     Horizontal hatch fill ------.
                        case esriSimpleFillStyle.esriSFSHorizontal:
                            supermapGeoStyle.FillSymbolID = 6;
                            break;
                        //
                        // 摘要:
                        //     Vertical hatch fill ||||||.
                        case esriSimpleFillStyle.esriSFSVertical:
                            supermapGeoStyle.FillSymbolID = 7;
                            break;
                        //
                        // 摘要:
                        //     45-degree downward, left-to-right hatch fill \\\.
                        case esriSimpleFillStyle.esriSFSForwardDiagonal:
                            supermapGeoStyle.FillSymbolID = 5;
                            break;
                        //
                        // 摘要:
                        //     45-degree upward, left-to-right hatch fill //////.
                        case esriSimpleFillStyle.esriSFSBackwardDiagonal:
                            supermapGeoStyle.FillSymbolID = 2;
                            break;
                        //
                        // 摘要:
                        //     Horizontal and vertical crosshatch ++++++.
                        case esriSimpleFillStyle.esriSFSCross:
                            supermapGeoStyle.FillSymbolID = 3;
                            break;
                        //
                        // 摘要:
                        //     45-degree crosshatch xxxxxx.
                        case esriSimpleFillStyle.esriSFSDiagonalCross:
                            supermapGeoStyle.FillSymbolID = 4;
                            break;
                    }
                }
                else if (pSymbol is GradientFillSymbol)
                {

                }
                else if (pSymbol is LineFillSymbol)
                {
                    ILineFillSymbol lineFillsymbol = pSymbol as ILineFillSymbol;

                }
                else if (pSymbol is MarkerFillSymbol)
                {


                }
                else if (pSymbol is DotDensityFillSymbol)
                {


                }
                else if (pSymbol is PictureFillSymbol)
                {


                }
                else
                {


                }

            }
        }

        public static void Log(string msg)
        {
            m_StreamWriter.Write(DateTime.Now.ToString("HH:mm:ss")+":");
            m_StreamWriter.WriteLine(msg);
            m_StreamWriter.Flush();
        }

        public static Colors translateColorRamp(IColorRamp colorRamp, LayerSettingGrid settingGrid, ILayer pLayer)
        {
            if (colorRamp is IAlgorithmicColorRamp)
            {
                IAlgorithmicColorRamp differentColors = colorRamp as IAlgorithmicColorRamp;
                IColor toColor = differentColors.ToColor;
                IColor fromColor = differentColors.FromColor;
                Color[] colors = new Color[2];
                colors[0] = ConvertToSystemColor(toColor);
                colors[1] = ConvertToSystemColor(fromColor);
                Colors supermapColors = Colors.MakeGradient(256, colors);
                settingGrid.ColorTable = supermapColors;
            }
            else if (colorRamp is MultiPartColorRamp)
            {
                IMultiPartColorRamp differentColors = colorRamp as IMultiPartColorRamp;

                Colors colorTable = new Colors();
                for (int k = 0;k < differentColors.NumberOfRamps;k++)
                {
                    IColorRamp itemRamp = differentColors.Ramp[k];
                    Colors colors = translateColorRamp(itemRamp, settingGrid, pLayer);
                    System.Collections.IEnumerator iterator = colors.GetEnumerator();
                    iterator.Reset();
                    
                    while(iterator.MoveNext())
                    {
                         colorTable.Add((Color)iterator.Current);
                    }
                   
                }
                settingGrid.ColorTable = colorTable;            
            }
            else if (colorRamp is PresetColorRamp)
            {
                Colors colorTable = new Colors();
                PresetColorRamp presetColorRamp = colorRamp as  PresetColorRamp;
                IEnumColors enumColors =  presetColorRamp.Colors;
                enumColors.Reset();
                IColor icolor = enumColors.Next();
                while (icolor != null)
                {
                    colorTable.Add(ConvertToSystemColor(icolor));
                    icolor = enumColors.Next();
                }
                settingGrid.ColorTable = colorTable;        
            }
            else if (colorRamp is RandomColorRamp)
            {
                Console.WriteLine("不支持RandomColorRamp 这样的随机色带");
                Log("Error:不支持RandomColorRamp 这样的色带");
                Log(String.Format("Error:图层 {0} 中的栅格专题类型 RasterClassifyColorRampRenderer中有supermap暂时不支持的属性", pLayer.Name));
            }

            return settingGrid.ColorTable;
        }


        public static void AnalyseEffects(IGeometricEffects pGeometricEffects)
        {
            int effectsCount = pGeometricEffects.Count;

            for (int i = 0; i < effectsCount; i++ )
            {
                IGeometricEffect effect = pGeometricEffects.get_Element(i);
 
                //                 Classes Description 
                // GeometricEffectAddControlPoints Assigns control point status to line vertices. 
                // GeometricEffectArrow Constructs an arrow of a given line. 
                // GeometricEffectBuffer Constructs a buffer polygon from any type of geometry. 
                // GeometricEffectCut Produces a shorter line based on distances at extremities. 
                // GeometricEffectDash Generates a dashed/dotted line based on a template. 
                // GeometricEffectDonut Inserts a hole into a polygon. 
                // GeometricEffectEnclosingPolygon Constructs enclosing polgon. With multipoint input, constructs a polygon that encloses all points. 
                // GeometricEffectExtension Extends a line by a given distance and deflection angle. 
                // GeometricEffectJog Constructs an Jog effect on a given line. 
                // GeometricEffectMove Applies a move transformation to a geometry. 
                // GeometricEffectOffset Offsets a line by a specified distance. 
                // GeometricEffectOffsetTangent Moves a line a given distance in the direction of one of its outermost segments. 
                // GeometricEffectRadial Produces a line from a point, based on direction and length. 
                // GeometricEffectRegularPolygon Creates a regular polygon from a point. 
                // GeometricEffectReverse Reverses the direction of a line. 
                // GeometricEffectRotate Applies a rotate transformation to a geometry. 
                // GeometricEffectScale Applies a scale transformation to a geometry. 
                // GeometricEffectSimplify Simplifies a geometry by eliminating vertices. 
                // GeometricEffectSmooth Smooth a geometry by approximation with beziers. 
                // GeometricEffectSuppress Suppresses part of a line or polygon outline. 
                // GeometricEffectTaperedPolygon Creates a taper polygon from a line. 
                // GeometricEffectWave Creates a regular wave from a curve.                 
               /////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
                // Graphic attributes for geometric effects.
                // 
                // Constant Value Description 
                // esriGAControlPointsTolerance 0 Angle tolerance attribute for AddControlPoint effect. 
                // esriGABufferSize 0 Buffer size attribute for Buffer effect. 
                // esriGACutCurveBegin 0 Begin cut attribute for CutCurve effect. 
                // esriGACutCurveEnd 1 End cut attribute for CutCurve effect. 
                // esriGACutCurveInvert 2 Invert attribute for CutCurve effect. 
                // esriGADashPattern 0 Pattern attribute for Dash effect. 
                // esriGADashEndings 1 Endings attribute for Dash effect. 
                // esriGADashPosition 2 Position attribute for Dash effect. 
                // esriGADashOffsetAtEnd 3 Offset At End attribute for Dash effect. 
                // esriGADonutWidth 0 Donut width attribute for Donut effect. 
                // esriGADonutSimple 1 Simple attribute for Donut effect. 
                // esriGADonutMethod 2 Method attribute for Donut effect. 
                // esriGAEnclosingPolygonMethod 0 Method for Enclosing Polygon effect. 
                // esriGAOffsetCurveOffset 0 Offset attribute for OffsetCurve effect. 
                // esriGAOffsetCurveMethod 1 Method attribute for OffsetCurve effect. 
                // esriGAOffsetCurveSimple 2 Simple attribute for OffsetCurve effect. Obsolete at 9.3. 
                // esriGAOffsetCurveOption 3 Option attribute for OffsetCurve effect. 
                // esriGAOffsetCurveCount 4 Count attribute for OffsetCurve effect. 
                // esriGARadialAngle 0 Angle attribute for Radial effect. 
                // esriGARadialLength 1 Length attribute for Radial effect. 
                // esriGAReverse 0 Reverse attribute for Reverse effect. 
                // esriGASimplifyTolerance 0 Tolerance attribute for Simplify effect. 
                // esriGASmoothTolerance 0 Tolerance attribute for Smooth effect. 
                // esriGARegularPolygonRadius 0 Radius attribute for Regular Polygon effect. 
                // esriGARegularPolygonEdges 1 Edges attribute for Regular Polygon effect. 
                // esriGARegularPolygonAngle 2 Angle attribute for Regular Polygon effect. 
                // esriGAWavePeriod 0 Period attribute for Wave effect. 
                // esriGAWaveWidth 1 Width attribute for Wave effect. 
                // esriGAWaveStyle 2 Style attribute for Wave effect. 
                // esriGAWaveSeed 3 Seed attribute for Wave effect. 
                // esriGAMoveXOffset 0 XOffset attribute for Move effect. 
                // esriGAMoveYOffset 1 YOffset attribute for Move effect. 
                // esriGAScaleXFactor 0 X Factor attribute for Scale effect. 
                // esriGAScaleYFactor 1 Y Factor attribute for Scale effect. 
                // esriGARotateAngle 0 Angle attribute for Rotate effect. 
                // esriGATaperedPolygonFromWidth 0 From width attribute for Tapered Polygon effect. 
                // esriGATaperedPolygonToWidth 1 To width attribute for Tapered Polygon effect. 
                // esriGATaperedPolygonLength 2 Length attribute for Tapered Polygon effect. 
                // esriGAArrowType 0 Type attribute for Arrow effect. 
                // esriGAArrowWidth 1 Width attribute for Arrow effect. 
                // esriGAJogLength 0 Length attribute for Jog effect. 
                // esriGAJogAngle 1 Angle attribute of the Jog effect. 
                // esriGAJogPosition 2 Distance attribute of the Jog effect. 
                // esriGAExtensionOrigin 0 Origin attribute for Extension effect. 
                // esriGAExtensionDeflection 1 Deflection attribute for Extension effect. 
                // esriGAExtensionLength 2 Length attribute for Extension effect. 
                // esriGAOffsetTangentMethod 0 Method attribute for Offset Tangent effect. 
                // esriGAOffsetTangentOffset 1 Offset attribute for Offset Tangent effect. 
                // esriGASuppressSuppress 
                

                if (effect is GeometricEffectTaperedPolygon)
                {
                    IGraphicAttributes graphicAttribute = effect as IGraphicAttributes;
                    double fromWith = (double)graphicAttribute.get_Value(0);
                    double toWith = (double)graphicAttribute.get_Value(1);
                    double length = (double)graphicAttribute.get_Value(2);

                    while (true)
                    {
                        IGeometry pGeometry = effect.NextGeometry();
                        if (pGeometry == null)
                        {
                            break;
                        }

                    }                   
                }
                else if (effect is GeometricEffectWave)
                {

                }
                else if (effect is GeometricEffectOffset)
                {

                }



            }
        }

    }
}